VOLGIT



LOG | FILES | OVERVIEW


F diff --git a/git_part.c b/git_part.c --- a/git_part.c +++ b/git_part.c
print_commit(current_commit,NULL,log_file,diff_directory_fd,repo);
git_revwalk_free(walker);
- fclose(log_file);
+ close_file(log_file);
}
void print_commit(git_commit *current_commit,git_commit *parent_commit,FILE *log_file,int diff_directory_fd,git_repository *repo)
{
push_html_link_for_blob(index_file,entry_name,entry_oid);
{
FILE *blob_file;
- const void *blob_data;
+ const unsigned char *blob_data;
size_t blob_size;
+ size_t i;
git_blob *blob;
+ static const char *special_chars[256]
+ =
+ {
+ ['\"']=""",
+ ['\'']="'",
+ ['&']="&",
+ ['<']="&lt;",
+ ['>']="&gt;",
+
+ };
+
blob=(git_blob*)obj;
blob_file=create_file(base_dir_fd,entry_oid);
blob_size=git_blob_rawsize(blob);
blob_data=git_blob_rawcontent(blob);
- fwrite(blob_data,blob_size,1,blob_file);
-
- fclose(blob_file);
+ fprintf(blob_file,"<code><pre>\n");
+ for(i=0;i<blob_size;++i)
+ {
+ if(special_chars[blob_data[i]])
+ {
+ fwrite(special_chars[blob_data[i]],1,strlen(special_chars[blob_data[i]]),blob_file);
+ }else
+ {
+ fwrite(blob_data+i,1,1,blob_file);
+ }
+ }
+ fprintf(blob_file,"</pre></code>\n");
+
+ close_file(blob_file);
}
break;
}