VirtualBox

Changeset 3217 in kBuild for trunk/src/kmk


Ignore:
Timestamp:
Mar 30, 2018 10:11:15 PM (7 years ago)
Author:
bird
Message:

kmk_cmp: changed to use getopt_r.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/cmp.c

    r3192 r3217  
    3535__RCSID("$NetBSD: cmp.c,v 1.15 2006/01/19 20:44:57 garbled Exp $"); */
    3636
     37/*********************************************************************************************************************************
     38*   Header Files                                                                                                                 *
     39*********************************************************************************************************************************/
     40#define FAKES_NO_GETOPT_H /* bird */
    3741#ifdef _MSC_VER
    3842# define MSC_DO_64_BIT_IO /* for correct off_t */
     
    5155# include "mscfakes.h"
    5256#endif
    53 #include "getopt.h"
     57#include "getopt_r.h"
    5458#include "kmkbuiltin.h"
    5559#include "cmp_extern.h"
    5660
    5761
     62/*********************************************************************************************************************************
     63*   Global Variables                                                                                                             *
     64*********************************************************************************************************************************/
    5865static const struct option long_options[] =
    5966{
     
    6976kmk_builtin_cmp(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx)
    7077{
     78    struct getopt_state_r gos;
    7179    off_t skip1 = 0, skip2 = 0;
    7280    int lflag = 0, sflag = 0;
     
    7482    char *file1, *file2;
    7583
    76 #ifdef KMK_BUILTIN_STANDALONE
    77     setlocale(LC_ALL, "");
    78 #endif
    79 
    80     /* reset getopt and set progname. */
    81     opterr = 1;
    82     optarg = NULL;
    83     optopt = 0;
    84     optind = 0; /* init */
    85 
    86     while ((ch = getopt_long(argc, argv, "ls", long_options, NULL)) != -1)
     84    getopt_initialize_r(&gos, argc, argv, "ls", long_options, envp, pCtx);
     85    while ((ch = getopt_long_r(&gos, NULL)) != -1)
    8786    {
    8887        switch (ch)
     
    104103        }
    105104    }
    106     argv += optind;
    107     argc -= optind;
     105    argv += gos.optind;
     106    argc -= gos.optind;
    108107
    109108    if (argc < 2 || argc > 4)
     
    148147{
    149148    KMKBUILTINCTX Ctx = { "kmk_cmp", NULL };
     149    setlocale(LC_ALL, "");
    150150    return kmk_builtin_cmp(argc, argv, envp, &Ctx);
    151151}
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