@@ -177,9 +177,9 @@ static void set_default_whitespace_mode(struct apply_state *state)
177
177
* of context lines.
178
178
*/
179
179
struct 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 ;
183
183
/*
184
184
* 'patch' is usually borrowed from buf in apply_patch(),
185
185
* but some codepaths store an allocated buffer.
@@ -423,9 +423,9 @@ static int read_patch_file(struct strbuf *sb, int fd)
423
423
return 0 ;
424
424
}
425
425
426
- static unsigned long linelen (const char * buffer , unsigned long size )
426
+ static size_t linelen (const char * buffer , size_t size )
427
427
{
428
- unsigned long len = 0 ;
428
+ size_t len = 0 ;
429
429
while (size -- ) {
430
430
len ++ ;
431
431
if (* buffer ++ == '\n' )
@@ -1321,7 +1321,7 @@ static int parse_git_header(struct apply_state *state,
1321
1321
unsigned int size ,
1322
1322
struct patch * patch )
1323
1323
{
1324
- unsigned long offset ;
1324
+ size_t offset ;
1325
1325
1326
1326
/* A git diff has explicit new/delete information, so we don't guess */
1327
1327
patch -> is_new = 0 ;
@@ -1391,7 +1391,7 @@ static int parse_git_header(struct apply_state *state,
1391
1391
return offset ;
1392
1392
}
1393
1393
1394
- static int parse_num (const char * line , unsigned long * p )
1394
+ static int parse_num (const char * line , size_t * p )
1395
1395
{
1396
1396
char * ptr ;
1397
1397
@@ -1402,7 +1402,7 @@ static int parse_num(const char *line, unsigned long *p)
1402
1402
}
1403
1403
1404
1404
static 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 )
1406
1406
{
1407
1407
int digits , ex ;
1408
1408
@@ -1517,19 +1517,19 @@ static int parse_fragment_header(const char *line, int len, struct fragment *fra
1517
1517
*/
1518
1518
static int find_header (struct apply_state * state ,
1519
1519
const char * line ,
1520
- unsigned long size ,
1520
+ size_t size ,
1521
1521
int * hdrsize ,
1522
1522
struct patch * patch )
1523
1523
{
1524
- unsigned long offset , len ;
1524
+ size_t offset , len ;
1525
1525
1526
1526
patch -> is_toplevel_relative = 0 ;
1527
1527
patch -> is_rename = patch -> is_copy = 0 ;
1528
1528
patch -> is_new = patch -> is_delete = -1 ;
1529
1529
patch -> old_mode = patch -> new_mode = 0 ;
1530
1530
patch -> old_name = patch -> new_name = NULL ;
1531
1531
for (offset = 0 ; size > 0 ; offset += len , size -= len , line += len , state -> linenr ++ ) {
1532
- unsigned long nextlen ;
1532
+ size_t nextlen ;
1533
1533
1534
1534
len = linelen (line , size );
1535
1535
if (!len )
@@ -1667,14 +1667,14 @@ static void check_old_for_crlf(struct patch *patch, const char *line, int len)
1667
1667
*/
1668
1668
static int parse_fragment (struct apply_state * state ,
1669
1669
const char * line ,
1670
- unsigned long size ,
1670
+ size_t size ,
1671
1671
struct patch * patch ,
1672
1672
struct fragment * fragment )
1673
1673
{
1674
1674
int added , deleted ;
1675
1675
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 ;
1678
1678
1679
1679
offset = parse_fragment_header (line , len , fragment );
1680
1680
if (offset < 0 )
@@ -1789,11 +1789,11 @@ static int parse_fragment(struct apply_state *state,
1789
1789
*/
1790
1790
static int parse_single_patch (struct apply_state * state ,
1791
1791
const char * line ,
1792
- unsigned long size ,
1792
+ size_t size ,
1793
1793
struct patch * patch )
1794
1794
{
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 ;
1797
1797
struct fragment * * fragp = & patch -> fragments ;
1798
1798
1799
1799
while (size > 4 && !memcmp (line , "@@ -" , 4 )) {
@@ -1864,8 +1864,8 @@ static inline int metadata_changes(struct patch *patch)
1864
1864
patch -> old_mode != patch -> new_mode );
1865
1865
}
1866
1866
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 )
1869
1869
{
1870
1870
git_zstream stream ;
1871
1871
void * out ;
@@ -1894,7 +1894,7 @@ static char *inflate_it(const void *data, unsigned long size,
1894
1894
*/
1895
1895
static struct fragment * parse_binary_hunk (struct apply_state * state ,
1896
1896
char * * buf_p ,
1897
- unsigned long * sz_p ,
1897
+ size_t * sz_p ,
1898
1898
int * status_p ,
1899
1899
int * used_p )
1900
1900
{
@@ -1911,10 +1911,10 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
1911
1911
* to 1-26 bytes, and 'a'-'z' corresponds to 27-52 bytes.
1912
1912
*/
1913
1913
int llen , used ;
1914
- unsigned long size = * sz_p ;
1914
+ size_t size = * sz_p ;
1915
1915
char * buffer = * buf_p ;
1916
1916
int patch_method ;
1917
- unsigned long origlen ;
1917
+ size_t origlen ;
1918
1918
char * data = NULL ;
1919
1919
int hunk_size = 0 ;
1920
1920
struct fragment * frag ;
@@ -2006,7 +2006,7 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,
2006
2006
*/
2007
2007
static int parse_binary (struct apply_state * state ,
2008
2008
char * buffer ,
2009
- unsigned long size ,
2009
+ size_t size ,
2010
2010
struct patch * patch )
2011
2011
{
2012
2012
/*
@@ -2123,7 +2123,7 @@ static int use_patch(struct apply_state *state, struct patch *p)
2123
2123
* the number of bytes consumed otherwise,
2124
2124
* so that the caller can call us again for the next patch.
2125
2125
*/
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 )
2127
2127
{
2128
2128
int hdrsize , patchsize ;
2129
2129
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
2153
2153
if (!patchsize ) {
2154
2154
static const char git_binary [] = "GIT binary patch\n" ;
2155
2155
int hd = hdrsize + offset ;
2156
- unsigned long llen = linelen (buffer + hd , size - hd );
2156
+ size_t llen = linelen (buffer + hd , size - hd );
2157
2157
2158
2158
if (llen == sizeof (git_binary ) - 1 &&
2159
2159
!memcmp (git_binary , buffer + hd , llen )) {
@@ -2397,7 +2397,7 @@ static void update_pre_post_images(struct image *preimage,
2397
2397
static int line_by_line_fuzzy_match (struct image * img ,
2398
2398
struct image * preimage ,
2399
2399
struct image * postimage ,
2400
- unsigned long current ,
2400
+ size_t current ,
2401
2401
int current_lno ,
2402
2402
int preimage_limit )
2403
2403
{
@@ -2466,7 +2466,7 @@ static int match_fragment(struct apply_state *state,
2466
2466
struct image * img ,
2467
2467
struct image * preimage ,
2468
2468
struct image * postimage ,
2469
- unsigned long current ,
2469
+ size_t current ,
2470
2470
int current_lno ,
2471
2471
unsigned ws_rule ,
2472
2472
int match_beginning , int match_end )
@@ -2677,7 +2677,7 @@ static int find_pos(struct apply_state *state,
2677
2677
int match_beginning , int match_end )
2678
2678
{
2679
2679
int i ;
2680
- unsigned long backwards , forwards , current ;
2680
+ size_t backwards , forwards , current ;
2681
2681
int backwards_lno , forwards_lno , current_lno ;
2682
2682
2683
2683
/*
@@ -2861,7 +2861,7 @@ static int apply_one_fragment(struct apply_state *state,
2861
2861
int new_blank_lines_at_end = 0 ;
2862
2862
int found_new_blank_lines_at_end = 0 ;
2863
2863
int hunk_linenr = frag -> linenr ;
2864
- unsigned long leading , trailing ;
2864
+ size_t leading , trailing ;
2865
2865
int pos , applied_pos ;
2866
2866
struct image preimage ;
2867
2867
struct image postimage ;
@@ -3085,9 +3085,9 @@ static int apply_one_fragment(struct apply_state *state,
3085
3085
*/
3086
3086
if ((leading != frag -> leading ||
3087
3087
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 " )"
3089
3089
" to apply fragment at %d" ),
3090
- leading , trailing , applied_pos + 1 );
3090
+ ( uintmax_t ) leading , ( uintmax_t ) trailing , applied_pos + 1 );
3091
3091
update_image (state , img , applied_pos , & preimage , & postimage );
3092
3092
} else {
3093
3093
if (state -> apply_verbosity > verbosity_normal )
@@ -3109,7 +3109,7 @@ static int apply_binary_fragment(struct apply_state *state,
3109
3109
struct patch * patch )
3110
3110
{
3111
3111
struct fragment * fragment = patch -> fragments ;
3112
- unsigned long len ;
3112
+ size_t len ;
3113
3113
void * dst ;
3114
3114
3115
3115
if (!fragment )
@@ -3199,7 +3199,7 @@ static int apply_binary(struct apply_state *state,
3199
3199
if (has_object_file (& oid )) {
3200
3200
/* We already have the postimage */
3201
3201
enum object_type type ;
3202
- unsigned long size ;
3202
+ size_t size ;
3203
3203
char * result ;
3204
3204
3205
3205
result = read_object_file (& oid , & type , & size );
@@ -3244,7 +3244,7 @@ static int apply_fragments(struct apply_state *state, struct image *img, struct
3244
3244
while (frag ) {
3245
3245
nth ++ ;
3246
3246
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 );
3248
3248
if (!state -> apply_with_reject )
3249
3249
return -1 ;
3250
3250
frag -> rejected = 1 ;
@@ -3261,7 +3261,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
3261
3261
strbuf_addf (buf , "Subproject commit %s\n" , oid_to_hex (oid ));
3262
3262
} else {
3263
3263
enum object_type type ;
3264
- unsigned long sz ;
3264
+ size_t sz ;
3265
3265
char * result ;
3266
3266
3267
3267
result = read_object_file (oid , & type , & sz );
@@ -4290,7 +4290,7 @@ static int add_index_file(struct apply_state *state,
4290
4290
const char * path ,
4291
4291
unsigned mode ,
4292
4292
void * buf ,
4293
- unsigned long size )
4293
+ size_t size )
4294
4294
{
4295
4295
struct stat st ;
4296
4296
struct cache_entry * ce ;
@@ -4344,7 +4344,7 @@ static int add_index_file(struct apply_state *state,
4344
4344
*/
4345
4345
static int try_create_file (struct apply_state * state , const char * path ,
4346
4346
unsigned int mode , const char * buf ,
4347
- unsigned long size )
4347
+ size_t size )
4348
4348
{
4349
4349
int fd , res ;
4350
4350
struct strbuf nbuf = STRBUF_INIT ;
@@ -4395,7 +4395,7 @@ static int create_one_file(struct apply_state *state,
4395
4395
char * path ,
4396
4396
unsigned mode ,
4397
4397
const char * buf ,
4398
- unsigned long size )
4398
+ size_t size )
4399
4399
{
4400
4400
int res ;
4401
4401
@@ -4487,7 +4487,7 @@ static int create_file(struct apply_state *state, struct patch *patch)
4487
4487
{
4488
4488
char * path = patch -> new_name ;
4489
4489
unsigned mode = patch -> new_mode ;
4490
- unsigned long size = patch -> resultsize ;
4490
+ size_t size = patch -> resultsize ;
4491
4491
char * buf = patch -> result ;
4492
4492
4493
4493
if (!mode )
0 commit comments