function.c (4ba3b38b64f33353b293c85335b88c2cb7f81d26) function.c (5a890aac5786247196ecf100b15ad678eaf80c26)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Cimarron D. Taylor of the University of California, Berkeley.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 124 unchanged lines hidden (view full) ---

133 /*
134 * Convert the string with strtoq(). Note, if strtoq() returns zero
135 * and endchar points to the beginning of the string we know we have
136 * a syntax error.
137 */
138 value = strtoq(str, &endchar, 10);
139 if (value == 0 && endchar == str)
140 errx(1, "%s: %s: illegal numeric value", option, vp);
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Cimarron D. Taylor of the University of California, Berkeley.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 124 unchanged lines hidden (view full) ---

133 /*
134 * Convert the string with strtoq(). Note, if strtoq() returns zero
135 * and endchar points to the beginning of the string we know we have
136 * a syntax error.
137 */
138 value = strtoq(str, &endchar, 10);
139 if (value == 0 && endchar == str)
140 errx(1, "%s: %s: illegal numeric value", option, vp);
141 if (endchar[0] && (endch == NULL || endchar[0] != *endch))
141 if (endchar[0] && endch == NULL)
142 errx(1, "%s: %s: illegal trailing character", option, vp);
143 if (endch)
144 *endch = endchar[0];
145 return value;
146}
147
148/*
149 * find_parsetime --

--- 1211 unchanged lines hidden (view full) ---

1361 return palloc(option);
1362}
1363
1364/*
1365 * -size n[c] functions --
1366 *
1367 * True if the file size in bytes, divided by an implementation defined
1368 * value and rounded up to the next integer, is n. If n is followed by
142 errx(1, "%s: %s: illegal trailing character", option, vp);
143 if (endch)
144 *endch = endchar[0];
145 return value;
146}
147
148/*
149 * find_parsetime --

--- 1211 unchanged lines hidden (view full) ---

1361 return palloc(option);
1362}
1363
1364/*
1365 * -size n[c] functions --
1366 *
1367 * True if the file size in bytes, divided by an implementation defined
1368 * value and rounded up to the next integer, is n. If n is followed by
1369 * a c, the size is in bytes.
1369 * one of c k M G T P, the size is in bytes, kilobytes,
1370 * megabytes, gigabytes, terabytes or petabytes respectively.
1370 */
1371#define FIND_SIZE 512
1372static int divsize = 1;
1373
1374int
1375f_size(PLAN *plan, FTSENT *entry)
1376{
1377 off_t size;

--- 4 unchanged lines hidden (view full) ---

1382}
1383
1384PLAN *
1385c_size(OPTION *option, char ***argvp)
1386{
1387 char *size_str;
1388 PLAN *new;
1389 char endch;
1371 */
1372#define FIND_SIZE 512
1373static int divsize = 1;
1374
1375int
1376f_size(PLAN *plan, FTSENT *entry)
1377{
1378 off_t size;

--- 4 unchanged lines hidden (view full) ---

1383}
1384
1385PLAN *
1386c_size(OPTION *option, char ***argvp)
1387{
1388 char *size_str;
1389 PLAN *new;
1390 char endch;
1391 off_t scale;
1390
1391 size_str = nextarg(option, argvp);
1392 ftsoptions &= ~FTS_NOSTAT;
1393
1394 new = palloc(option);
1395 endch = 'c';
1396 new->o_data = find_parsenum(new, option->name, size_str, &endch);
1392
1393 size_str = nextarg(option, argvp);
1394 ftsoptions &= ~FTS_NOSTAT;
1395
1396 new = palloc(option);
1397 endch = 'c';
1398 new->o_data = find_parsenum(new, option->name, size_str, &endch);
1397 if (endch == 'c')
1399 if (endch != '\0') {
1398 divsize = 0;
1400 divsize = 0;
1401
1402 switch (endch) {
1403 case 'c': /* characters */
1404 scale = 0x1LL;
1405 break;
1406 case 'k': /* kilobytes 1<<10 */
1407 scale = 0x400LL;
1408 break;
1409 case 'M': /* megabytes 1<<20 */
1410 scale = 0x100000LL;
1411 break;
1412 case 'G': /* gigabytes 1<<30 */
1413 scale = 0x40000000LL;
1414 break;
1415 case 'T': /* terabytes 1<<40 */
1416 scale = 0x1000000000LL;
1417 break;
1418 case 'P': /* petabytes 1<<50 */
1419 scale = 0x4000000000000LL;
1420 break;
1421 default:
1422 errx(1, "%s: %s: illegal trailing character",
1423 option->name, size_str);
1424 break;
1425 }
1426 if (new->o_data > QUAD_MAX / scale)
1427 errx(1, "%s: %s: value too large",
1428 option->name, size_str);
1429 new->o_data *= scale;
1430 }
1399 return new;
1400}
1401
1402/*
1403 * -type c functions --
1404 *
1405 * True if the type of the file is c, where c is b, c, d, p, f or w
1406 * for block special file, character special file, directory, FIFO,

--- 199 unchanged lines hidden ---
1431 return new;
1432}
1433
1434/*
1435 * -type c functions --
1436 *
1437 * True if the type of the file is c, where c is b, c, d, p, f or w
1438 * for block special file, character special file, directory, FIFO,

--- 199 unchanged lines hidden ---