Skip to content

Commit 1a60cf9

Browse files
committed
Use our getopt implementation on all platforms
* rename xgetopt.* to sc_getopt.*, move to src/base * rename getopt() to sc_getopt()
1 parent fb45e4e commit 1a60cf9

8 files changed

Lines changed: 27 additions & 247 deletions

File tree

src/base/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
set(SCL_BASE_SOURCES
33
scl_memmgr.cc
44
scl_trace_fprintf.c
5-
)
6-
7-
include_directories(
8-
${SCL_SOURCE_DIR}/include
5+
sc_getopt.cc
96
)
107

118
if(MSVC OR BORLAND)
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
/****** RENAMED from xgetopt.cc to sc_getopt.cc ***********/
2+
13
// XGetopt.cpp Version 1.2
24
//
35
// Author: Hans Dietrich
46
// hdietrich2@hotmail.com
57
//
68
// Description:
7-
// XGetopt.cpp implements getopt(), a function to parse command lines.
9+
// XGetopt.cpp implements sc_getopt(), a function to parse command lines.
810
//
911
// History
1012
// Version 1.2 - 2003 May 17
@@ -36,29 +38,29 @@
3638
#include <string.h>
3739
///////////////////////////////////////////////////////////////////////////////
3840

39-
#include "XGetopt.h"
41+
#include "sc_getopt.h"
4042

4143
///////////////////////////////////////////////////////////////////////////////
4244
//
4345
// X G e t o p t . c p p
4446
//
4547
//
4648
// NAME
47-
// getopt -- parse command line options
49+
// sc_getopt -- parse command line options
4850
//
4951
// SYNOPSIS
50-
// int getopt(int argc, char *argv[], char *optstring)
52+
// int sc_getopt(int argc, char *argv[], char *optstring)
5153
//
5254
// extern char *optarg;
5355
// extern int optind;
5456
//
5557
// DESCRIPTION
56-
// The getopt() function parses the command line arguments. Its
58+
// The sc_getopt() function parses the command line arguments. Its
5759
// arguments argc and argv are the argument count and array as
5860
// passed into the application on program invocation. In the case
5961
// of Visual C++ programs, argc and argv are available via the
6062
// variables __argc and __argv (double underscores), respectively.
61-
// getopt returns the next option letter in argv that matches a
63+
// sc_getopt returns the next option letter in argv that matches a
6264
// letter in optstring. (Note: Unicode programs should use
6365
// __targv instead of __argv. Also, all character and string
6466
// literals should be enclosed in _T( ) ).
@@ -67,17 +69,17 @@
6769
// is followed by a colon, the option is expected to have an argument
6870
// that may or may not be separated from it by white space. optarg
6971
// is set to point to the start of the option argument on return from
70-
// getopt.
72+
// sc_getopt.
7173
//
7274
// Option letters may be combined, e.g., "-ab" is equivalent to
7375
// "-a -b". Option letters are case sensitive.
7476
//
75-
// getopt places in the external variable optind the argv index
77+
// sc_getopt places in the external variable optind the argv index
7678
// of the next argument to be processed. optind is initialized
77-
// to 0 before the first call to getopt.
79+
// to 0 before the first call to sc_getopt.
7880
//
7981
// When all options have been processed (i.e., up to the first
80-
// non-option argument), getopt returns EOF, optarg will point
82+
// non-option argument), sc_getopt returns EOF, optarg will point
8183
// to the argument, and optind will be set to the argv index of
8284
// the argument. If there are no non-option arguments, optarg
8385
// will be set to NULL.
@@ -87,8 +89,8 @@
8789
// will be skipped.
8890
//
8991
// RETURN VALUE
90-
// For option letters contained in the string optstring, getopt
91-
// will return the option letter. getopt returns a question mark (?)
92+
// For option letters contained in the string optstring, sc_getopt
93+
// will return the option letter. sc_getopt returns a question mark (?)
9294
// when it encounters an option letter not included in optstring.
9395
// EOF is returned when processing is finished.
9496
//
@@ -98,15 +100,15 @@
98100
// 3) The environment variable POSIXLY_CORRECT is not supported.
99101
// 4) The + syntax is not supported.
100102
// 5) The automatic permutation of arguments is not supported.
101-
// 6) This implementation of getopt() returns EOF if an error is
103+
// 6) This implementation of sc_getopt() returns EOF if an error is
102104
// encountered, instead of -1 as the latest standard requires.
103105
//
104106
// EXAMPLE
105107
// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
106108
// {
107109
// int c;
108110
//
109-
// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
111+
// while ((c = sc_getopt(argc, argv, _T("aBn:"))) != EOF)
110112
// {
111113
// switch (c)
112114
// {
@@ -153,7 +155,7 @@
153155
char * optarg; // global argument pointer
154156
int optind = 0; // global argv index
155157

156-
int getopt( int argc, char * argv[], char * optstring ) {
158+
int sc_getopt( int argc, char * argv[], char * optstring ) {
157159
static char * next = NULL;
158160
if( optind == 0 ) {
159161
next = NULL;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/****** RENAMED from xgetopt.h to sc_getopt.h ***********/
12
// XGetopt.h Version 1.2
23
//
34
// Author: Hans Dietrich
@@ -22,7 +23,7 @@ extern "C" {
2223
extern int optind, opterr;
2324
extern char * optarg;
2425

25-
int getopt( int argc, char * argv[], char * optstring );
26+
int sc_getopt( int argc, char * argv[], char * optstring );
2627

2728
#ifdef __cplusplus
2829
}

src/express/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ SET(CHECK_EXPRESS_SOURCES
5656

5757
IF(MSVC OR BORLAND)
5858
set(CHECK_EXPRESS_EXTRA_SOURCES
59-
xgetopt.cc
60-
inithook.c
59+
inithook.c
6160
)
6261
ENDIF()
6362

src/express/fedex.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@
8484
/* process.h defines getpid() function on WIN32 systems */
8585
# include <process.h>
8686
#endif
87-
#ifndef HAVE_GETOPT
88-
# include "xgetopt.h"
89-
#endif
87+
#include "sc_getopt.h"
9088
#include "express/error.h"
9189
#include "express/express.h"
9290
#include "express/resolve.h"
@@ -159,7 +157,7 @@ int main( int argc, char ** argv ) {
159157
}
160158

161159
optind = 1;
162-
while( ( c = getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 )
160+
while( ( c = sc_getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 )
163161
switch( c ) {
164162
case 'd':
165163
ERRORdebugging = 1;

src/fedex_plus/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ include_directories(
2828
${SCL_SOURCE_DIR}/src/base
2929
)
3030

31-
IF(MSVC OR BORLAND)
32-
set(fedex_plus_EXTRA_SOURCES xgetopt.cc )
33-
ENDIF()
34-
3531
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
3632
add_definitions( -DYYDEBUG ) #-Ddebugging )
3733
ENDIF()
3834

39-
SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES} ${fedex_plus_EXTRA_SOURCES}" "libexppp express base")
35+
SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES}" "libexppp express base")
4036

4137
add_dependencies( fedex_plus version_string )

src/fedex_plus/xgetopt.cc

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)