@@ -177,9 +177,9 @@ static void set_default_whitespace_mode(struct apply_state *state)
177177 * of context lines.
178178 */
179179struct fragment {
180- unsigned long leading , trailing ;
181- unsigned long oldpos , oldlines ;
182- unsigned long newpos , newlines ;
180+ size_t leading , trailing ;
181+ size_t oldpos , oldlines ;
182+ size_t newpos , newlines ;
183183 /*
184184 * 'patch' is usually borrowed from buf in apply_patch(),
185185 * but some codepaths store an allocated buffer.
@@ -423,9 +423,9 @@ static int read_patch_file(struct strbuf *sb, int fd)
423423 return 0 ;
424424}
425425
426- static unsigned long linelen (const char * buffer , unsigned long size )
426+ static size_t linelen (const char * buffer , size_t size )
427427{
428- unsigned long len = 0 ;
428+ size_t len = 0 ;
429429 while (size -- ) {
430430 len ++ ;
431431 if (* buffer ++ == '\n' )
@@ -1321,7 +1321,7 @@ static int parse_git_header(struct apply_state *state,
13211321 unsigned int size ,
13221322 struct patch * patch )
13231323{
1324- unsigned long offset ;
1324+ size_t offset ;
13251325
13261326 /* A git diff has explicit new/delete information, so we don't guess */
13271327 patch -> is_new = 0 ;
@@ -1391,7 +1391,7 @@ static int parse_git_header(struct apply_state *state,
13911391 return offset ;
13921392}
13931393
1394- static int parse_num (const char * line , unsigned long * p )
1394+ static int parse_num (const char * line , size_t * p )
13951395{
13961396 char * ptr ;
13971397
@@ -1402,7 +1402,7 @@ static int parse_num(const char *line, unsigned long *p)
14021402}
14031403
14041404static int parse_range (const char * line , int len , int offset , const char * expect ,
1405- unsigned long * p1 , unsigned long * p2 )
1405+ size_t * p1 , size_t * p2 )
14061406{
14071407 int digits , ex ;
14081408
@@ -1517,19 +1517,19 @@ static int parse_fragment_header(const char *line, int len, struct fragment *fra
15171517 */
15181518static int find_header (struct apply_state * state ,
15191519 const char * line ,
1520- unsigned long size ,
1520+ size_t size ,
15211521 int * hdrsize ,
15221522 struct patch * patch )
15231523{
1524- unsigned long offset , len ;
1524+ size_t offset , len ;
15251525
15261526 patch -> is_toplevel_relative = 0 ;
15271527 patch -> is_rename = patch -> is_copy = 0 ;
15281528 patch -> is_new = patch -> is_delete = -1 ;
15291529 patch -> old_mode = patch -> new_mode = 0 ;
15301530 patch -> old_name = patch -> new_name = NULL ;
15311531 for (offset = 0 ; size > 0 ; offset += len , size -= len , line += len , state -> linenr ++ ) {
1532- unsigned long nextlen ;
1532+ size_t nextlen ;
15331533
15341534 len = linelen (line , size );
15351535 if (!len )
@@ -1667,14 +1667,14 @@ static void check_old_for_crlf(struct patch *patch, const char *line, int len)
16671667 */
16681668static int parse_fragment (struct apply_state * state ,
16691669 const char * line ,
1670- unsigned long size ,
1670+ size_t size ,
16711671 struct patch * patch ,
16721672 struct fragment * fragment )
16731673{
16741674 int added , deleted ;
16751675 int len = linelen (line , size ), offset ;
1676- unsigned long oldlines , newlines ;
1677- unsigned long leading , trailing ;
1676+ size_t oldlines , newlines ;
1677+ size_t leading , trailing ;
16781678
16791679 offset = parse_fragment_header (line , len , fragment );
16801680 if (offset < 0 )
@@ -1789,11 +1789,11 @@ static int parse_fragment(struct apply_state *state,
17891789 */
17901790static int parse_single_patch (struct apply_state * state ,
17911791 const char * line ,
1792- unsigned long size ,
1792+ size_t size ,
17931793 struct patch * patch )
17941794{
1795- unsigned long offset = 0 ;
1796- unsigned long oldlines = 0 , newlines = 0 , context = 0 ;
1795+ size_t offset = 0 ;
1796+ size_t oldlines = 0 , newlines = 0 , context = 0 ;
17971797 struct fragment * * fragp = & patch -> fragments ;
17981798
17991799 while (size > 4 && !memcmp (line , "@@ -" , 4 )) {
@@ -1864,8 +1864,8 @@ static inline int metadata_changes(struct patch *patch)
18641864 patch -> old_mode != patch -> new_mode );
18651865}
18661866
1867- static char * inflate_it (const void * data , unsigned long size ,
1868- unsigned long inflated_size )
1867+ static char * inflate_it (const void * data , size_t size ,
1868+ size_t inflated_size )
18691869{
18701870 git_zstream stream ;
18711871 void * out ;
@@ -1894,7 +1894,7 @@ static char *inflate_it(const void *data, unsigned long size,
18941894 */
18951895static struct fragment * parse_binary_hunk (struct apply_state * state ,
18961896 char * * buf_p ,
1897- unsigned long * sz_p ,
1897+ size_t * sz_p ,
18981898 int * status_p ,
18991899 int * used_p )
19001900{
@@ -1911,10 +1911,10 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
19111911 * to 1-26 bytes, and 'a'-'z' corresponds to 27-52 bytes.
19121912 */
19131913 int llen , used ;
1914- unsigned long size = * sz_p ;
1914+ size_t size = * sz_p ;
19151915 char * buffer = * buf_p ;
19161916 int patch_method ;
1917- unsigned long origlen ;
1917+ size_t origlen ;
19181918 char * data = NULL ;
19191919 int hunk_size = 0 ;
19201920 struct fragment * frag ;
@@ -2006,7 +2006,7 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
20062006 */
20072007static int parse_binary (struct apply_state * state ,
20082008 char * buffer ,
2009- unsigned long size ,
2009+ size_t size ,
20102010 struct patch * patch )
20112011{
20122012 /*
@@ -2123,7 +2123,7 @@ static int use_patch(struct apply_state *state, struct patch *p)
21232123 * the number of bytes consumed otherwise,
21242124 * so that the caller can call us again for the next patch.
21252125 */
2126- static int parse_chunk (struct apply_state * state , char * buffer , unsigned long size , struct patch * patch )
2126+ static int parse_chunk (struct apply_state * state , char * buffer , size_t size , struct patch * patch )
21272127{
21282128 int hdrsize , patchsize ;
21292129 int offset = find_header (state , buffer , size , & hdrsize , patch );
@@ -2153,7 +2153,7 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si
21532153 if (!patchsize ) {
21542154 static const char git_binary [] = "GIT binary patch\n" ;
21552155 int hd = hdrsize + offset ;
2156- unsigned long llen = linelen (buffer + hd , size - hd );
2156+ size_t llen = linelen (buffer + hd , size - hd );
21572157
21582158 if (llen == sizeof (git_binary ) - 1 &&
21592159 !memcmp (git_binary , buffer + hd , llen )) {
@@ -2397,7 +2397,7 @@ static void update_pre_post_images(struct image *preimage,
23972397static int line_by_line_fuzzy_match (struct image * img ,
23982398 struct image * preimage ,
23992399 struct image * postimage ,
2400- unsigned long current ,
2400+ size_t current ,
24012401 int current_lno ,
24022402 int preimage_limit )
24032403{
@@ -2466,7 +2466,7 @@ static int match_fragment(struct apply_state *state,
24662466 struct image * img ,
24672467 struct image * preimage ,
24682468 struct image * postimage ,
2469- unsigned long current ,
2469+ size_t current ,
24702470 int current_lno ,
24712471 unsigned ws_rule ,
24722472 int match_beginning , int match_end )
@@ -2677,7 +2677,7 @@ static int find_pos(struct apply_state *state,
26772677 int match_beginning , int match_end )
26782678{
26792679 int i ;
2680- unsigned long backwards , forwards , current ;
2680+ size_t backwards , forwards , current ;
26812681 int backwards_lno , forwards_lno , current_lno ;
26822682
26832683 /*
@@ -2861,7 +2861,7 @@ static int apply_one_fragment(struct apply_state *state,
28612861 int new_blank_lines_at_end = 0 ;
28622862 int found_new_blank_lines_at_end = 0 ;
28632863 int hunk_linenr = frag -> linenr ;
2864- unsigned long leading , trailing ;
2864+ size_t leading , trailing ;
28652865 int pos , applied_pos ;
28662866 struct image preimage ;
28672867 struct image postimage ;
@@ -3085,9 +3085,9 @@ static int apply_one_fragment(struct apply_state *state,
30853085 */
30863086 if ((leading != frag -> leading ||
30873087 trailing != frag -> trailing ) && state -> apply_verbosity > verbosity_silent )
3088- fprintf_ln (stderr , _ ("Context reduced to (%ld/%ld )"
3088+ fprintf_ln (stderr , _ ("Context reduced to (%" PRIuMAX "/%" PRIuMAX " )"
30893089 " to apply fragment at %d" ),
3090- leading , trailing , applied_pos + 1 );
3090+ ( uintmax_t ) leading , ( uintmax_t ) trailing , applied_pos + 1 );
30913091 update_image (state , img , applied_pos , & preimage , & postimage );
30923092 } else {
30933093 if (state -> apply_verbosity > verbosity_normal )
@@ -3109,7 +3109,7 @@ static int apply_binary_fragment(struct apply_state *state,
31093109 struct patch * patch )
31103110{
31113111 struct fragment * fragment = patch -> fragments ;
3112- unsigned long len ;
3112+ size_t len ;
31133113 void * dst ;
31143114
31153115 if (!fragment )
@@ -3199,7 +3199,7 @@ static int apply_binary(struct apply_state *state,
31993199 if (has_object_file (& oid )) {
32003200 /* We already have the postimage */
32013201 enum object_type type ;
3202- unsigned long size ;
3202+ size_t size ;
32033203 char * result ;
32043204
32053205 result = read_object_file (& oid , & type , & size );
@@ -3244,7 +3244,7 @@ static int apply_fragments(struct apply_state *state, struct image *img, struct
32443244 while (frag ) {
32453245 nth ++ ;
32463246 if (apply_one_fragment (state , img , frag , inaccurate_eof , ws_rule , nth )) {
3247- error (_ ("patch failed: %s:%ld" ), name , frag -> oldpos );
3247+ error (_ ("patch failed: %s:%" PRIuMAX ), name , ( uintmax_t ) frag -> oldpos );
32483248 if (!state -> apply_with_reject )
32493249 return -1 ;
32503250 frag -> rejected = 1 ;
@@ -3261,7 +3261,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
32613261 strbuf_addf (buf , "Subproject commit %s\n" , oid_to_hex (oid ));
32623262 } else {
32633263 enum object_type type ;
3264- unsigned long sz ;
3264+ size_t sz ;
32653265 char * result ;
32663266
32673267 result = read_object_file (oid , & type , & sz );
@@ -4290,7 +4290,7 @@ static int add_index_file(struct apply_state *state,
42904290 const char * path ,
42914291 unsigned mode ,
42924292 void * buf ,
4293- unsigned long size )
4293+ size_t size )
42944294{
42954295 struct stat st ;
42964296 struct cache_entry * ce ;
@@ -4344,7 +4344,7 @@ static int add_index_file(struct apply_state *state,
43444344 */
43454345static int try_create_file (struct apply_state * state , const char * path ,
43464346 unsigned int mode , const char * buf ,
4347- unsigned long size )
4347+ size_t size )
43484348{
43494349 int fd , res ;
43504350 struct strbuf nbuf = STRBUF_INIT ;
@@ -4395,7 +4395,7 @@ static int create_one_file(struct apply_state *state,
43954395 char * path ,
43964396 unsigned mode ,
43974397 const char * buf ,
4398- unsigned long size )
4398+ size_t size )
43994399{
44004400 int res ;
44014401
@@ -4487,7 +4487,7 @@ static int create_file(struct apply_state *state, struct patch *patch)
44874487{
44884488 char * path = patch -> new_name ;
44894489 unsigned mode = patch -> new_mode ;
4490- unsigned long size = patch -> resultsize ;
4490+ size_t size = patch -> resultsize ;
44914491 char * buf = patch -> result ;
44924492
44934493 if (!mode )
0 commit comments