@@ -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
/*
@@ -2851,7 +2851,7 @@ static int apply_one_fragment(struct apply_state *state,
2851
2851
int new_blank_lines_at_end = 0 ;
2852
2852
int found_new_blank_lines_at_end = 0 ;
2853
2853
int hunk_linenr = frag -> linenr ;
2854
- unsigned long leading , trailing ;
2854
+ size_t leading , trailing ;
2855
2855
int pos , applied_pos ;
2856
2856
struct image preimage ;
2857
2857
struct image postimage ;
@@ -3075,9 +3075,9 @@ static int apply_one_fragment(struct apply_state *state,
3075
3075
*/
3076
3076
if ((leading != frag -> leading ||
3077
3077
trailing != frag -> trailing ) && state -> apply_verbosity > verbosity_silent )
3078
- fprintf_ln (stderr , _ ("Context reduced to (%ld/%ld )"
3078
+ fprintf_ln (stderr , _ ("Context reduced to (%" PRIuMAX "/%" PRIuMAX " )"
3079
3079
" to apply fragment at %d" ),
3080
- leading , trailing , applied_pos + 1 );
3080
+ ( uintmax_t ) leading , ( uintmax_t ) trailing , applied_pos + 1 );
3081
3081
update_image (state , img , applied_pos , & preimage , & postimage );
3082
3082
} else {
3083
3083
if (state -> apply_verbosity > verbosity_normal )
@@ -3099,7 +3099,7 @@ static int apply_binary_fragment(struct apply_state *state,
3099
3099
struct patch * patch )
3100
3100
{
3101
3101
struct fragment * fragment = patch -> fragments ;
3102
- unsigned long len ;
3102
+ size_t len ;
3103
3103
void * dst ;
3104
3104
3105
3105
if (!fragment )
@@ -3189,7 +3189,7 @@ static int apply_binary(struct apply_state *state,
3189
3189
if (has_object_file (& oid )) {
3190
3190
/* We already have the postimage */
3191
3191
enum object_type type ;
3192
- unsigned long size ;
3192
+ size_t size ;
3193
3193
char * result ;
3194
3194
3195
3195
result = read_object_file (& oid , & type , & size );
@@ -3234,7 +3234,7 @@ static int apply_fragments(struct apply_state *state, struct image *img, struct
3234
3234
while (frag ) {
3235
3235
nth ++ ;
3236
3236
if (apply_one_fragment (state , img , frag , inaccurate_eof , ws_rule , nth )) {
3237
- error (_ ("patch failed: %s:%ld" ), name , frag -> oldpos );
3237
+ error (_ ("patch failed: %s:%" PRIuMAX ), name , ( uintmax_t ) frag -> oldpos );
3238
3238
if (!state -> apply_with_reject )
3239
3239
return -1 ;
3240
3240
frag -> rejected = 1 ;
@@ -3251,7 +3251,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
3251
3251
strbuf_addf (buf , "Subproject commit %s\n" , oid_to_hex (oid ));
3252
3252
} else {
3253
3253
enum object_type type ;
3254
- unsigned long sz ;
3254
+ size_t sz ;
3255
3255
char * result ;
3256
3256
3257
3257
result = read_object_file (oid , & type , & sz );
@@ -4280,7 +4280,7 @@ static int add_index_file(struct apply_state *state,
4280
4280
const char * path ,
4281
4281
unsigned mode ,
4282
4282
void * buf ,
4283
- unsigned long size )
4283
+ size_t size )
4284
4284
{
4285
4285
struct stat st ;
4286
4286
struct cache_entry * ce ;
@@ -4334,7 +4334,7 @@ static int add_index_file(struct apply_state *state,
4334
4334
*/
4335
4335
static int try_create_file (struct apply_state * state , const char * path ,
4336
4336
unsigned int mode , const char * buf ,
4337
- unsigned long size )
4337
+ size_t size )
4338
4338
{
4339
4339
int fd , res ;
4340
4340
struct strbuf nbuf = STRBUF_INIT ;
@@ -4385,7 +4385,7 @@ static int create_one_file(struct apply_state *state,
4385
4385
char * path ,
4386
4386
unsigned mode ,
4387
4387
const char * buf ,
4388
- unsigned long size )
4388
+ size_t size )
4389
4389
{
4390
4390
int res ;
4391
4391
@@ -4477,7 +4477,7 @@ static int create_file(struct apply_state *state, struct patch *patch)
4477
4477
{
4478
4478
char * path = patch -> new_name ;
4479
4479
unsigned mode = patch -> new_mode ;
4480
- unsigned long size = patch -> resultsize ;
4480
+ size_t size = patch -> resultsize ;
4481
4481
char * buf = patch -> result ;
4482
4482
4483
4483
if (!mode )
0 commit comments