VirtualBox

Changeset 3214 in kBuild


Ignore:
Timestamp:
Mar 30, 2018 9:03:40 PM (7 years ago)
Author:
bird
Message:

kmk_install: use getopt_r.

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.kmk

    r3192 r3214  
    106106        kmkbuiltin/kbuild_protection.c \
    107107        kmkbuiltin/common-env-and-cwd-opt.c \
     108        kmkbuiltin/getopt_r.c \
     109        kmkbuiltin/getopt1_r.c \
    108110        getopt.c \
    109111        getopt1.c \
  • trunk/src/kmk/kmkbuiltin/install.c

    r3192 r3214  
    4747#endif
    4848
     49#define FAKES_NO_GETOPT_H
    4950#include "config.h"
    5051#ifndef _MSC_VER
     
    7980# include <process.h>
    8081#endif
    81 #include "getopt.h"
     82#include "getopt_r.h"
    8283#ifdef __sun__
    8384# include "solfakes.h"
     
    175176{
    176177        INSTALLINSTANCE This;
     178        struct getopt_state_r gos;
    177179        struct stat from_sb, to_sb;
    178180        mode_t *set;
     
    203205        This.dos2unix = 0;
    204206
    205         /* reset getopt and set progname. */
    206         opterr = 1;
    207         optarg = NULL;
    208         optopt = 0;
    209         optind = 0; /* init */
    210 
    211207        iflags = 0;
    212208        group = owner = NULL;
    213         while ((ch = getopt_long(argc, argv, "B:bCcdf:g:Mm:o:pSsv", long_options, NULL)) != -1)
     209        getopt_initialize_r(&gos, argc, argv, "B:bCcdf:g:Mm:o:pSsv", long_options, envp, pCtx);
     210        while ((ch = getopt_long_r(&gos, NULL)) != -1)
    214211                switch(ch) {
    215212                case 'B':
    216                         This.suffix = optarg;
     213                        This.suffix = gos.optarg;
    217214                        /* FALLTHROUGH */
    218215                case 'b':
     
    239236                        break;
    240237                case 'g':
    241                         group = optarg;
     238                        group = gos.optarg;
    242239                        break;
    243240                case 'M':
     
    245242                        break;
    246243                case 'm':
    247                         if (!(set = bsd_setmode(optarg)))
    248                                 return errx(pCtx, EX_USAGE, "invalid file mode: %s", optarg);
     244                        if (!(set = bsd_setmode(gos.optarg)))
     245                                return errx(pCtx, EX_USAGE, "invalid file mode: %s", gos.optarg);
    249246                        This.mode = bsd_getmode(set, 0);
    250247                        free(set);
     
    252249                        break;
    253250                case 'o':
    254                         owner = optarg;
     251                        owner = gos.optarg;
    255252                        break;
    256253                case 'p':
     
    293290                        return usage(pCtx, 1);
    294291                }
    295         argc -= optind;
    296         argv += optind;
     292        argc -= gos.optind;
     293        argv += gos.optind;
    297294
    298295        /* some options make no sense when creating directories */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette