is_numeric(arg) ? (char)getvar_i(arg) : *getvar_s(arg));
} else if (c == 's') {
- s1 = getvar_s(arg);
+ s1 = getvar_s(arg);
qrealloc(&b, incr+i+strlen(s1), &bsize);
i += sprintf(b+i, s, s1);
R.d--;
goto r_op_change;
case '!':
- L.d = istrue(X.v) ? 0 : 1;
+ L.d = istrue(X.v) ? 0 : 1;
break;
case '-':
L.d = -R.d;
if(bbg.hold_space) free(bbg.hold_space);
- while(bbg.current_input_file<bbg.input_file_count)
+ while(bbg.current_input_file<bbg.input_file_count)
fclose(bbg.input_file_list[bbg.current_input_file++]);
}
#endif
if (file_modified) {
#ifdef CONFIG_FEATURE_VI_READONLY
if (vi_readonly || readonly) {
- psbs("\"%s\" File is read only", cfn);
- break;
+ psbs("\"%s\" File is read only", cfn);
+ break;
}
#endif /* CONFIG_FEATURE_VI_READONLY */
cnt = file_write(cfn, text, end - 1);
if (PRINT_MATCH_COUNTS) {
if (print_filename > 0)
printf("%s:", cur_file);
- printf("%d\n", nmatches);
+ printf("%d\n", nmatches);
}
/* grep -l: print just the filename, but only if we grepped the line in the file */
i = 0;
while (*p) {
- if (*p < '0' || *p > '9') {
- if (*p == '.') {
- i = scan_ip(&ipm, mask, 0);
- return i != 32;
- }
- return -1;
+ if (*p < '0' || *p > '9') {
+ if (*p == '.') {
+ i = scan_ip(&ipm, mask, 0);
+ return i != 32;
}
- i *= 10;
- i += *p - '0';
- p++;
+ return -1;
+ }
+ i *= 10;
+ i += *p - '0';
+ p++;
}
}
if (i > 32 || i < 0)
- return -1;
+ return -1;
msk = 0x80000000;
*mask = 0;
while (i > 0) {
} else if ((cf[1] == '.') && (cf[2] == '/' || cf[2] == 0)) {
++cf;
if (p > p0) {
- while (*--p != '/'); /* omit previous dir */
+ while (*--p != '/') /* omit previous dir */;
}
continue;
}
/* protect out root */
goto BAD_REQUEST;
}
- while (*--purl != '/'); /* omit previous dir */
- continue;
+ while (*--purl != '/') /* omit previous dir */;
+ continue;
}
}
}
if (matches(opt, "-family") == 0) {
argc--;
argv++;
- if (! argv[1])
- bb_show_usage();
+ if (!argv[1])
+ bb_show_usage();
if (strcmp(argv[1], "inet") == 0)
preferred_family = AF_INET;
else if (strcmp(argv[1], "inet6") == 0)
}
outbuf[j++] = *p;
if (*p == 0xff)
- outbuf[j++] = 0xff;
+ outbuf[j++] = 0xff;
else if (*p == 0x0d)
- outbuf[j++] = 0x00;
+ outbuf[j++] = 0x00;
}
if (j > 0 )
- write(G.netfd, outbuf, j);
+ write(G.netfd, outbuf, j);
}
outicmp->icmp_cksum = 0xffff;
} else
#endif
- if (doipcksum) {
+ if (doipcksum) {
/* Checksum (we must save and restore ip header) */
tip = *outip;
ui = (struct udpiphdr *)outip;
return (type == ICMP_TIMXCEED ? -1 : code + 1);
} else
#endif
- {
+ {
up = (struct udphdr *)((unsigned char *)hip + hlen);
/* XXX 8 is a magic number */
if (hlen + 12 <= cc &&
if(nprobes_str)
nprobes = str2val(nprobes_str, "nprobes", 1, -1);
if(source) {
- /*
- * set the ip source address of the outbound
- * probe (e.g., on a multi-homed host).
- */
- if (getuid()) bb_error_msg_and_die("-s %s: Permission denied", source);
+ /*
+ * set the ip source address of the outbound
+ * probe (e.g., on a multi-homed host).
+ */
+ if (getuid()) bb_error_msg_and_die("-s %s: permission denied", source);
}
if(waittime_str)
waittime = str2val(waittime_str, "wait time", 2, 24 * 60 * 60);
for(l_sr = sourse_route_list; l_sr; ) {
if (lsrr >= NGATEWAYS)
- bb_error_msg_and_die("No more than %d gateways", NGATEWAYS);
+ bb_error_msg_and_die("no more than %d gateways", NGATEWAYS);
getaddr(gwlist + lsrr, l_sr->data);
++lsrr;
l_sr = l_sr->link;
if (num < 4)
while (num-- > 0)
putchar('\b');
-
else
printf("\033[%dD", num);
} else {
pbuf = buf2;
*pbuf = '~';
strcpy(pbuf+1, pwd_buf+l);
- }
+ }
break;
#endif
case 'W':
s[l++] = *found++;
}
if(add)
- s[l++] = (char)add;
+ s[l++] = (char)add;
s[l] = 0;
return s;
}
for (row = 0; row < nrows; row++) {
l = strlen(matches[row]);
if(add_char_to_match[row])
- l++;
+ l++;
if (column_width < l)
column_width = l;
}
printf("%s%s", matches[n], str_add_chr);
l = strlen(matches[n]);
while(l < acol) {
- putchar(' ');
- l++;
+ putchar(' ');
+ l++;
}
}
str_add_chr[0] = add_char_to_match[n];
int i, j, n, srt;
/* bubble */
n = num_matches;
- for(i=0; i<(n-1); i++)
- for(j=i+1; j<n; j++)
- if(matches[i]!=NULL && matches[j]!=NULL) {
- srt = strcmp(matches[i], matches[j]);
- if(srt == 0) {
- free(matches[j]);
- matches[j]=0;
- } else if(srt > 0) {
- tmp1 = matches[i];
- matches[i] = matches[j];
- matches[j] = tmp1;
- srt = add_char_to_match[i];
- add_char_to_match[i] = add_char_to_match[j];
- add_char_to_match[j] = srt;
- }
+ for(i=0; i<(n-1); i++) {
+ for(j=i+1; j<n; j++) {
+ if(matches[i]!=NULL && matches[j]!=NULL) {
+ srt = strcmp(matches[i], matches[j]);
+ if(srt == 0) {
+ free(matches[j]);
+ matches[j]=0;
+ } else if(srt > 0) {
+ tmp1 = matches[i];
+ matches[i] = matches[j];
+ matches[j] = tmp1;
+ srt = add_char_to_match[i];
+ add_char_to_match[i] = add_char_to_match[j];
+ add_char_to_match[j] = srt;
+ }
+ }
}
+ }
j = n;
n = 0;
for(i=0; i<j; i++)
- if(matches[i]) {
- matches[n]=matches[i];
- add_char_to_match[n]=add_char_to_match[i];
- n++;
- }
+ if(matches[i]) {
+ matches[n]=matches[i];
+ add_char_to_match[n]=add_char_to_match[i];
+ n++;
+ }
num_matches = n;
}
/* Did we find exactly one match? */
/* fall through */
case 'd'|vbit:
{
- int nc, sc;
- sc = cursor;
- prevc = ic;
- if (safe_read(0, &c, 1) < 1)
- goto prepare_to_die;
- if (c == (prevc & 0xff)) {
- /* "cc", "dd" */
- input_backward(cursor);
- goto clear_to_eol;
- break;
- }
- switch(c) {
- case 'w':
- case 'W':
- case 'e':
- case 'E':
- switch (c) {
- case 'w': /* "dw", "cw" */
- vi_word_motion(command, vi_cmdmode);
- break;
- case 'W': /* 'dW', 'cW' */
- vi_Word_motion(command, vi_cmdmode);
- break;
- case 'e': /* 'de', 'ce' */
- vi_end_motion(command);
- input_forward();
- break;
- case 'E': /* 'dE', 'cE' */
- vi_End_motion(command);
- input_forward();
- break;
- }
- nc = cursor;
- input_backward(cursor - sc);
- while (nc-- > cursor)
- input_delete(1);
- break;
- case 'b': /* "db", "cb" */
- case 'B': /* implemented as B */
- if (c == 'b')
- vi_back_motion(command);
- else
- vi_Back_motion(command);
- while (sc-- > cursor)
- input_delete(1);
- break;
- case ' ': /* "d ", "c " */
- input_delete(1);
- break;
- case '$': /* "d$", "c$" */
- clear_to_eol:
- while (cursor < len)
- input_delete(1);
- break;
- }
+ int nc, sc;
+ sc = cursor;
+ prevc = ic;
+ if (safe_read(0, &c, 1) < 1)
+ goto prepare_to_die;
+ if (c == (prevc & 0xff)) {
+ /* "cc", "dd" */
+ input_backward(cursor);
+ goto clear_to_eol;
+ break;
+ }
+ switch(c) {
+ case 'w':
+ case 'W':
+ case 'e':
+ case 'E':
+ switch (c) {
+ case 'w': /* "dw", "cw" */
+ vi_word_motion(command, vi_cmdmode);
+ break;
+ case 'W': /* 'dW', 'cW' */
+ vi_Word_motion(command, vi_cmdmode);
+ break;
+ case 'e': /* 'de', 'ce' */
+ vi_end_motion(command);
+ input_forward();
+ break;
+ case 'E': /* 'dE', 'cE' */
+ vi_End_motion(command);
+ input_forward();
+ break;
+ }
+ nc = cursor;
+ input_backward(cursor - sc);
+ while (nc-- > cursor)
+ input_delete(1);
+ break;
+ case 'b': /* "db", "cb" */
+ case 'B': /* implemented as B */
+ if (c == 'b')
+ vi_back_motion(command);
+ else
+ vi_Back_motion(command);
+ while (sc-- > cursor)
+ input_delete(1);
+ break;
+ case ' ': /* "d ", "c " */
+ input_delete(1);
+ break;
+ case '$': /* "d$", "c$" */
+ clear_to_eol:
+ while (cursor < len)
+ input_delete(1);
+ break;
+ }
}
break;
case 'p'|vbit:
static void xioctl(int fd, int request, void *argp, const char *string)
{
- if (ioctl (fd, request, argp) < 0) {
+ if (ioctl(fd, request, argp) < 0) {
bb_perror_msg_and_die(string);
}
}
argv += optind;
/* R_OK is needed for verifying */
- if (stat(*argv,&st) < 0 || access(*argv,W_OK | R_OK ) < 0) {
- bb_perror_msg_and_die("%s",*argv);
+ if (stat(*argv, &st) < 0 || access(*argv, W_OK | R_OK ) < 0) {
+ bb_perror_msg_and_die("%s", *argv);
}
if (!S_ISBLK(st.st_mode)) {
- bb_error_msg_and_die("%s: not a block device",*argv);
+ bb_error_msg_and_die("%s: not a block device", *argv);
/* do not test major - perhaps this was an USB floppy */
}
-
/* O_RDWR for formatting and verifying */
- fd = xopen(*argv,O_RDWR );
+ fd = xopen(*argv, O_RDWR);
xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */
param.track, param.sect, param.size >> 1);
/* FORMAT */
- printf("Formatting ... ");
- xioctl(fd, FDFMTBEG,NULL,"FDFMTBEG");
+ printf("Formatting... ");
+ xioctl(fd, FDFMTBEG, NULL, "FDFMTBEG");
/* n == track */
- for (n = 0; n < param.track; n++)
- {
- descr.head = 0;
- descr.track = n;
- xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK");
- printf("%3d\b\b\b", n);
- if (param.head == 2) {
- descr.head = 1;
- xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK");
- }
+ for (n = 0; n < param.track; n++) {
+ descr.head = 0;
+ descr.track = n;
+ xioctl(fd, FDFMTTRK, &descr, "FDFMTTRK");
+ printf("%3d\b\b\b", n);
+ if (param.head == 2) {
+ descr.head = 1;
+ xioctl(fd, FDFMTTRK, &descr, "FDFMTTRK");
+ }
}
- xioctl(fd,FDFMTEND,NULL,"FDFMTEND");
+ xioctl(fd, FDFMTEND, NULL, "FDFMTEND");
printf("done\n");
/* VERIFY */
- if(verify) {
+ if (verify) {
/* n == cyl_size */
n = param.sect*param.head*512;
data = xmalloc(n);
- printf("Verifying ... ");
+ printf("Verifying... ");
for (cyl = 0; cyl < param.track; cyl++) {
printf("%3d\b\b\b", cyl);
- if((read_bytes = safe_read(fd,data,n))!= n ) {
- if(read_bytes < 0) {
+ read_bytes = safe_read(fd, data, n);
+ if (read_bytes != n) {
+ if (read_bytes < 0) {
bb_perror_msg(bb_msg_read_error);
}
- bb_error_msg_and_die("Problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes);
+ bb_error_msg_and_die("problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes);
+ // FIXME: maybe better seek & continue??
}
/* Check backwards so we don't need a counter */
- while(--read_bytes>=0) {
- if( data[read_bytes] != FD_FILL_BYTE) {
- printf("bad data in cyl %d\nContinuing ... ",cyl);
+ while (--read_bytes >= 0) {
+ if (data[read_bytes] != FD_FILL_BYTE) {
+ printf("bad data in cyl %d\nContinuing... ",cyl);
}
}
}
label_sun != current_label_type && !get_nr_sects(p))
{
printf(_("Partition %d does not exist yet!\n"), i + 1);
- }else{
- while (1) {
+ } else while (1) {
sys = read_hex (get_sys_types());
if (!sys && label_sgi != current_label_type &&
dos_changed = 1;
break;
}
- }
}
}
#endif /* CONFIG_FEATURE_FDISK_WRITABLE */
} else {
action = getenv("ACTION");
env_path = getenv("DEVPATH");
- if (!action || !env_path)
+ if (!action || !env_path)
bb_show_usage();
sprintf(temp, "/sys%s", env_path);