whpcvt.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 2,343 行 · 第 1/5 页
C
2,343 行
int argc,
char *argv[]
) {
int i;
int start_arg;
for( start_arg = 0; start_arg < argc; ++start_arg ) {
if( argv[start_arg][0] == '-' || argv[start_arg][0] == '/' ) {
for( i = 0; Args[i] != NULL; ++i ) {
if( stricmp( Args[i], &argv[start_arg][1] ) == 0 ) {
break;
}
}
switch( i ) {
case ARG_DPT:
Dump_popup_t = TRUE;
break;
case ARG_DPI:
Dump_popup_i = TRUE;
break;
case ARG_DPK:
Dump_popup_k = TRUE;
break;
case ARG_DPB:
Dump_popup_b = TRUE;
break;
case ARG_UP:
Do_up = TRUE;
break;
case ARG_KB:
Do_kw_button = TRUE;
break;
case ARG_I:
Do_index = TRUE;
break;
case ARG_KW:
Do_keywords = TRUE;
break;
case ARG_B:
Do_blist = TRUE;
break;
case ARG_S:
Browse_sort = TRUE;
break;
case ARG_K:
Keep_titles = TRUE;
break;
case ARG_EX:
Exclude_special = TRUE;
break;
case ARG_H:
Do_def = TRUE;
break;
case ARG_HH:
Do_hdef = TRUE;
break;
case ARG_HN:
Do_ctx_ids = TRUE;
break;
case ARG_XL:
Start_inc_sl = INDENT_INC;
Start_inc_ol = INDENT_INC;
Start_inc_dl = INDENT_INC;
Start_inc_ul = INDENT_INC;
break;
case ARG_DL:
Start_inc_dl = INDENT_INC;
break;
case ARG_SL:
Start_inc_sl = INDENT_INC;
break;
case ARG_OL:
Start_inc_ol = INDENT_INC;
break;
case ARG_UL:
Start_inc_ul = INDENT_INC;
break;
case ARG_IW:
Index_gml_fmt = FALSE;
break;
case ARG_RTF:
Output_type = OUT_RTF;
break;
case ARG_IPF:
Output_type = OUT_IPF;
break;
case ARG_IB:
Output_type = OUT_IB;
break;
case ARG_HTML:
Output_type = OUT_HTML;
break;
case ARG_WIKI:
Output_type = OUT_WIKI;
break;
case ARG_BL:
Break_link = TRUE;
break;
case ARG_T:
Do_contents = TRUE;
break;
case ARG_E:
Remove_empty = TRUE;
break;
case ARG_RF:
Real_ipf_font = TRUE;
break;
case ARG_LK:
Keep_link_topics = TRUE;
break;
case ARG_KT:
Do_topic_keyword=FALSE;
break;
case ARG_RM:
start_arg++;
if( start_arg < argc ) {
Right_Margin = atoi( argv[ start_arg ] );
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_TAB:
start_arg++;
if( start_arg < argc ) {
Text_Indent = atoi( argv[ start_arg ] );
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_HD:
start_arg++;
if( start_arg < argc ) {
strncpy( Header_File, argv[ start_arg ], 100 );
Header_File[99] = '\0';
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_FT:
start_arg++;
if( start_arg < argc ) {
strncpy( Header_File, argv[ start_arg ], 100 );
Header_File[99] = '\0';
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_HB:
Hyper_Brace_L = IB_BRACE_L_CHAR;
Hyper_Brace_R = IB_BRACE_R_CHAR;
break;
case ARG_BR:
Do_browse = TRUE;
break;
case ARG_TC:
Do_tc_button = TRUE;
break;
case ARG_IX:
Do_idx_button = TRUE;
break;
case ARG_TL:
++start_arg;
if( start_arg < argc ) {
_new( Ipf_title, strlen( argv[start_arg] ) + 1 );
strcpy( Ipf_title, argv[start_arg] );
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_MC:
Title_case = TITLE_CASE_MIXED;
break;
case ARG_DT:
++start_arg;
if( start_arg < argc ) {
_new( IB_def_topic, strlen( argv[start_arg] ) + 1 );
strcpy( IB_def_topic, argv[start_arg] );
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_DS:
++start_arg;
if( start_arg < argc ) {
_new( IB_help_desc, strlen( argv[start_arg] ) + 1 );
strcpy( IB_help_desc, argv[start_arg] );
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
case ARG_OF:
++start_arg;
if( start_arg < argc ) {
_new( Options_file, strlen( argv[start_arg] ) + 1 );
strcpy( Options_file, argv[start_arg] );
} else {
error( ERR_BAD_ARGS, FALSE );
}
break;
default:
return( 0 );
}
} else {
break;
}
}
return( start_arg );
}
static int valid_args(
/********************/
int argc,
char *argv[]
) {
int start_arg;
FILE *opt_file;
char line[200];
int ret;
int i;
char *x;
Tab_xmp = FALSE;
Start_inc_ul = 0;
Start_inc_ol = 0;
Start_inc_sl = 0;
Start_inc_dl = 0;
Browse_sort = FALSE;
Do_index = FALSE;
Do_contents = FALSE;
Keep_titles = FALSE;
Exclude_special = FALSE;
Do_def = FALSE;
Do_hdef = FALSE;
Do_ctx_ids = FALSE;
Do_blist = FALSE;
Do_up = FALSE;
Do_kw_button = FALSE;
Index_gml_fmt=TRUE;
Brace_count = 0;
Output_type = OUT_RTF;
Break_link = FALSE;
Do_contents = FALSE;
Remove_empty = FALSE;
Real_ipf_font = FALSE;
Keep_link_topics = FALSE;
Do_topic_keyword = TRUE;
Dump_popup_t = FALSE;
Dump_popup_i = FALSE;
Dump_popup_b = FALSE;
Dump_popup_k = FALSE;
Right_Margin = 76;
Header_File[0] = '\0';
Footer_File[0] = '\0';
Text_Indent = 4;
Hyper_Brace_L = IB_HLINK_L_CHAR;
Hyper_Brace_R = IB_HLINK_R_CHAR;
Do_browse = FALSE;
Do_tc_button = FALSE;
Do_idx_button = FALSE;
Title_case = TITLE_CASE_UPPER;
start_arg = process_args( argc, argv );
if( start_arg < argc - 2 || start_arg >= argc ) {
return( -1 );
}
for( ;; ) {
if( Options_file != NULL ) {
opt_file = fopen( Options_file, "r" );
if( opt_file == NULL ) {
return( -1 );
}
for( argc = 0 ;; ++argc ) {
if( fgets( line, 200, opt_file ) == NULL ) {
break;
}
}
fclose( opt_file );
opt_file = fopen( Options_file, "r" );
free( Options_file );
Options_file = NULL;
_new( argv, argc );
for( argc = 0;; ++argc ) {
if( fgets( line, 200, opt_file ) == NULL ) {
break;
}
line[199] = 0;
for (x = line, i = 0; i < 200 && *x != 0; i++, x++) {
if ( *x != ' ' && *x != 9 ) {
strcpy (line, x);
break;
}
}
for (i = strlen( line ), x = line + i - 1; i > 0; i--, x--) {
if (*x == '\n' || *x == ' ' || *x == 9) {
*x = 0;
} else {
break;
}
}
_new( argv[argc], i + 1 );
strcpy( argv[argc], line );
}
fclose( opt_file );
ret = process_args( argc, argv );
for( i = 0 ; i < argc; ++i ) {
free( argv[i] );
}
free( argv );
if( ret != argc ) {
return( -1 );
}
} else {
break;
}
}
return( start_arg );
}
char *skip_blank(
/***************/
char *ptr
) {
for( ; *ptr == ' ' || *ptr == '\t'; ++ptr );
return( ptr );
}
bool read_line( void )
/********************/
{
int ch;
char *buf;
int len;
bool eat_blank;
eat_blank = FALSE;
for( ;; ) {
++Line_num;
for( buf = Line_buf, len = 0;; ++buf ) {
#if defined __QNX__ || defined __UNIX__
do {
ch = fgetc( In_file );
} while( ch == '\r' );
#else
ch = fgetc( In_file );
#endif
if( ch == EOF ) {
return( FALSE );
}
++len;
if( len > Line_buf_size ) {
Line_buf_size += BUF_GROW;
Line_buf = _realloc( Line_buf, Line_buf_size );
buf = &Line_buf[len-1];
}
if( ch == 255 ) {
ch = 32; // convert special blanks to regular blanks
}
*buf = (char)ch;
if( *buf == '\n' ) {
if( eat_blank ) {
eat_blank = FALSE;
if( *skip_blank( Line_buf ) == '\n' ) {
/* the 'exclude off, but eat blank line after' character
is used to do 'dummy' figures (to get the the
figure numbers right). Since real text has
to get ejected, an extra blank line is hard to
prevent. So this is used to eat one blank line
after the fake figure */
break;
}
}
if( *Line_buf == CH_EXCLUDE_OFF ) {
Exclude_on = FALSE;
break;
} else if( *Line_buf == CH_EXCLUDE_OFF_BLANK ) {
Exclude_on = FALSE;
eat_blank = TRUE;
break;
} else if( *Line_buf == CH_EXCLUDE_ON ) {
Exclude_on = TRUE;
break;
} else if( Exclude_on ) {
break;
} else {
*buf = '\0';
return( TRUE );
}
}
}
}
}
char *whole_keyword_line(
/***********************/
char *ptr
) {
char buf[100];
char *end;
/* this is a kludge case! If a line contains nothing but keywords,
then parse it without generating a blank line. This
can happen in GML when people use index entries to generate
keywords, so we have to look for this case */
for( ; *ptr == CH_CTX_KW; ) {
end = strchr( ptr + 1, CH_CTX_KW );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?