536 * argument into the list.
537 */
538
539 mav_num = (size_t)ac+2;
540
541 if ((mav = calloc(mav_num, sizeof (char *))) == NULL) {
542 perror("chmod");
543 exit(2);
544 }
545
546 /* scan for the use of "--" in the argument list */
547
548 for (fflag = i = 0; i < ac; i ++) {
549 if (strcmp(av[i], "--") == 0)
550 fflag = 1;
551 }
552
553 /* process the arguments */
554
555 for (i = mac = 0;
556 (av[i] != (char *)NULL) && (av[i][0] != (char)NULL);
557 i++) {
558 if (!fflag && av[i][0] == '-') {
559 /*
560 * If there is not already a "--" argument specified,
561 * and the argument starts with '-' but does not
562 * contain any of the official option letters, then it
563 * is probably a mode argument beginning with '-'.
564 * Force a "--" into the argument stream in front of
565 * it.
566 */
567
568 if ((strchr(av[i], 'R') == NULL &&
569 strchr(av[i], 'f') == NULL) &&
570 strchr(av[i], '@') == NULL) {
571 if ((mav[mac++] = strdup("--")) == NULL) {
572 perror("chmod");
573 exit(2);
574 }
575 }
576 }
|
536 * argument into the list.
537 */
538
539 mav_num = (size_t)ac+2;
540
541 if ((mav = calloc(mav_num, sizeof (char *))) == NULL) {
542 perror("chmod");
543 exit(2);
544 }
545
546 /* scan for the use of "--" in the argument list */
547
548 for (fflag = i = 0; i < ac; i ++) {
549 if (strcmp(av[i], "--") == 0)
550 fflag = 1;
551 }
552
553 /* process the arguments */
554
555 for (i = mac = 0;
556 (av[i] != NULL) && (av[i][0] != '\0');
557 i++) {
558 if (!fflag && av[i][0] == '-') {
559 /*
560 * If there is not already a "--" argument specified,
561 * and the argument starts with '-' but does not
562 * contain any of the official option letters, then it
563 * is probably a mode argument beginning with '-'.
564 * Force a "--" into the argument stream in front of
565 * it.
566 */
567
568 if ((strchr(av[i], 'R') == NULL &&
569 strchr(av[i], 'f') == NULL) &&
570 strchr(av[i], '@') == NULL) {
571 if ((mav[mac++] = strdup("--")) == NULL) {
572 perror("chmod");
573 exit(2);
574 }
575 }
576 }
|