Skip to content

Commit 49e415b

Browse files
author
Nicholas Reed
committed
rename getopt to sc_getopt and include it as part of base lib; SCL git 1a60cf9 and dd93a96
1 parent 760bb54 commit 49e415b

7 files changed

Lines changed: 27 additions & 41 deletions

File tree

data/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,8 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
9797
set_tests_properties( generate_cpp_${SCHEMA_SHORT_NAME} PROPERTIES LABELS cpp_schema_gen )
9898
set_tests_properties( build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${SCHEMA_SHORT_NAME} LABELS cpp_schema_build )
9999

100-
if(MSVC OR BORLAND)
101-
add_executable( p21read_${PROJECT_NAME} ${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc ${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc )
102-
else()
103-
add_executable( p21read_${PROJECT_NAME} ${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc )
104-
endif()
100+
SCL_ADDEXEC( p21read_${PROJECT_NAME} "${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc" "${PROJECT_NAME};base" )
105101
add_dependencies( p21read_${PROJECT_NAME} version_string )
106-
target_link_libraries( p21read_${PROJECT_NAME} ${PROJECT_NAME} )
107102
set_target_properties( p21read_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
108103
${${PROJECT_NAME}_COMPILE_FLAGS} )
109104
TESTABLE_TARGET( p21read_${PROJECT_NAME} )

src/base/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11

22
set(SCL_BASE_SOURCES
33
scl_memmgr.cc
4-
)
5-
6-
include_directories(
7-
${CMAKE_CURRENT_BINARY_DIR}
8-
${CMAKE_CURRENT_SOURCE_DIR}
9-
${SCL_SOURCE_DIR}/include
4+
sc_getopt.cc
105
)
116

127
option(SCL_MEMMGR_ENABLE_CHECKS "Enable scl_memmgr's memory leak detection" OFF)
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: 5 additions & 3 deletions
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
@@ -14,15 +15,16 @@
1415

1516
#ifndef XGETOPT_H
1617
#define XGETOPT_H
18+
#include "scl_export.h"
1719

1820
#ifdef __cplusplus
1921
extern "C" {
2022
#endif
2123

22-
extern int optind, opterr;
23-
extern char * optarg;
24+
extern SCL_BASE_EXPORT int optind, opterr;
25+
extern SCL_BASE_EXPORT char * optarg;
2426

25-
int getopt( int argc, char * argv[], char * optstring );
27+
int SCL_BASE_EXPORT sc_getopt( int argc, char * argv[], char * optstring );
2628

2729
#ifdef __cplusplus
2830
}

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"
@@ -152,7 +150,7 @@ int main( int argc, char ** argv ) {
152150
}
153151

154152
optind = 1;
155-
while( ( c = getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 )
153+
while( ( c = sc_getopt( argc, argv, EXPRESSgetopt_options ) ) != -1 )
156154
switch( c ) {
157155
case 'd':
158156
ERRORdebugging = 1;

src/fedex_plus/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ include_directories(
3131
${SCL_SOURCE_DIR}/src/base
3232
)
3333
IF(MSVC OR BORLAND)
34-
set(fedex_plus_EXTRA_SOURCES
35-
xgetopt.cc
36-
)
3734
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
3835
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
3936
add_definitions( -DSCL_BASE_DLL_IMPORTS )

src/fedex_python/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ include_directories(
1111
add_definitions( -DHAVE_CONFIG_H )
1212

1313
IF(MSVC)
14-
set(fedex_plus_MSVC_SOURCES
15-
../fedex_plus/xgetopt.cc
16-
)
1714
add_definitions( -DSCL_BASE_DLL_IMPORTS )
1815
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
1916
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
@@ -40,7 +37,7 @@ set(fedex_python_SOURCES
4037
../fedex_plus/write.cc
4138
../fedex_plus/print.cc
4239
)
43-
SCL_ADDEXEC(fedex_python "${fedex_python_SOURCES};${fedex_plus_MSVC_SOURCES}" "libexppp;express;base")
40+
SCL_ADDEXEC(fedex_python "${fedex_python_SOURCES}" "libexppp;express;base")
4441

4542
add_dependencies( fedex_python version_string )
4643
endif(SCL_PYTHON_GENERATOR)

0 commit comments

Comments
 (0)