📄 commands.c
字号:
/* case 4 */
string_ptr = get_strtok(buff, ii, max_ind, -1, &start_ind);
if (string_ptr)
{
if (strnicmp(string_ptr, end_string, strlen(end_string)) != 0)
{
klammer1 = 'f'; /* "<token>" */
found = 4;
strncpy (token_string, string_ptr, sizeof(token_string));
ii = start_ind;
break;
}
else
{
string_ptr = get_strtok(buff, (start_ind + strlen(end_string)), max_ind, 1, &start_ind);
if (string_ptr)
{
klammer1 = 'n'; /* "e(n)d <token>" */
found = 4;
strncpy (token_string, string_ptr, sizeof(token_string));
start_level = -1;
break;
}
}
} /* if string_ptr */
} /* if is_visible_token */
} /* for ii */
if (found == 0)
{
err_message (NO_CORRESPONDING_BRACKET);
return index_1; /* nix gefunden */
}
/* ------------------------------------------------------------------- */
/* welche klammer war's denn ? */
if ((klammer1 == '(') ||
(klammer1 == '{') ||
(klammer1 == '[') ||
(klammer1 == '<') ||
(klammer1 == 'f'))
{
direction = 1;
}
else
{
if (klammer1 != 'l') /* special case "#else": keep old direction */
direction = -1;
}
if (direction == 1)
{
i1 = ii;
i2 = max_ind;
/* ggf. suchbereich reduzieren */
if (found == 2)
i2 -= (strlen(string_c[3] ) - 1); /* "#endif" */
if (found == 3)
i2 -= (strlen(string_ada1[3]) - 1); /* "end if" */
if (found == 4)
i2 -= (strlen(string_ptr) - 1); /* "loop" */
}
else
{
i1 = ii;
i2 = -1;
}
/* bestimme klammer2 */
if (klammer1 == '(') klammer2 = ')';
if (klammer1 == ')') klammer2 = '(';
if (klammer1 == '{') klammer2 = '}';
if (klammer1 == '}') klammer2 = '{';
if (klammer1 == '[') klammer2 = ']';
if (klammer1 == ']') klammer2 = '[';
if (klammer1 == '<') klammer2 = '>';
if (klammer1 == '>') klammer2 = '<';
/* ------------------------------------------------------------------- */
/* search corresponding bracket */
level = start_level;
for (ii = i1 ; ii != i2 ; ii += direction)
{
if (is_visible_token(buff, ii, max_ind, 0, direction))
{
switch (found)
{
case 1:
if (buff[ii] == klammer1) level++;
if (buff[ii] == klammer2) level--;
break;
case 2:
if (strncmp(&buff[ii], string_c[0], strlen(string_c[0])) == 0) level++; /* == #if */
if (strncmp(&buff[ii], string_c[3], strlen(string_c[3])) == 0) level--; /* == #endif */
if ((strncmp(&buff[ii], string_c[1], strlen(string_c[1])) == 0) || /* == #else */
(strncmp(&buff[ii], string_c[2], strlen(string_c[2])) == 0)) /* == #elif */
{
if (level == direction)
return ii; /* gefunden !! */
if (level == 0)
level = direction;
}
break;
case 3:
if (is_delimiter(buff[max(0, (ii - 1))]))
{
if (( strnicmp(&buff[ii], string_ada1[3], strlen(string_ada1[3])) == 0) && /* == end if */
is_delimiter(buff[min(max_ind, (ii + (int)strlen(string_ada1[3])))]))
{
level--;
}
else if(((strnicmp(&buff[ii], string_ada1[1], strlen(string_ada1[1])) == 0) && /* == else */
is_delimiter(buff[min(max_ind, (ii + (int)strlen(string_ada1[1])))])) ||
((strnicmp(&buff[ii], string_ada1[2], strlen(string_ada1[2])) == 0) && /* == elsif */
is_delimiter(buff[min(max_ind, (ii + (int)strlen(string_ada1[2])))])))
{
if (level == direction)
return ii; /* gefunden !! */
if (level == 0)
level = direction;
}
else if ((strnicmp(&buff[ii], string_ada1[0], strlen(string_ada1[0])) == 0) && /* == if */
(strnicmp(&buff[max(0,ii-4)], string_ada1[3], strlen(string_ada1[3])) != 0) && /* != end if */
is_delimiter(buff[min(max_ind, (ii + (int)strlen(string_ada1[0])))]))
{
level++;
}
}
break;
case 4:
if ((strnicmp(&buff[ii], token_string, strlen(token_string)) == 0) && /* is buff found ? */
is_delimiter(buff[max(0 , (ii - 1)) ]) && /* is found buff a delimited token ? */
is_delimiter(buff[min(max_ind, (ii + (int)strlen(token_string)))]))
{
string_ptr = get_strtok(buff, (ii - strlen(end_string)), max_ind, -1, &start_ind);
if (string_ptr)
{
if (strnicmp(string_ptr, end_string, strlen(end_string)) == 0)
{
offset = (ii - start_ind); /* point to begin of "end xxxx" */
level--;
}
else
{
offset = 0;
level++;
}
}
}
break;
default:
break;
} /* switch found */
} /* if is_visible_token */
if (level == 0) return (ii - offset); /* gefunden !! */
} /* for ii */
/* no match */
err_message (NO_CORRESPONDING_BRACKET);
return index_1; /* nix gefunden */
} /* comm_ctrl_k */
/* -FF- */
int parse_input_string (char *string)
{
/* Command "Quit/Init" erhaelt als kommando-string:
entweder : "filename"
oder : "filename vo" (view_only)
Dieser string wird hier in seine Bestandteile (1 oder 2) zerlegt:
Der filename wird im input-string begrenzt (durch setzen von '\0'),
die option wird als return value uebergeben.
*/
int ii, view_only;
view_only = 0; /* default */
/* analyze input_string */
#if (ACT_OP_SYSTEM != WIN_32)
for (ii = 0 ; ii < BUF_256 ; ii++)
{
if (*string == 0) break; /* reached end of string */
/* end of filename ? */
if (isspace(*string))
{
*string = '\0'; /* mark end of filename */
string++;
break;
}
/* next char */
string++;
}
/* look for "VO" */
for (ii = 0 ; ii < BUF_256 ; ii++)
{
if (*string == '\0') break; /* reached end of string */
/* begin of option ? */
if ((stricmp (string, "vo") == 0) ||
(stricmp (string, "viewonly") == 0))
{
view_only = 1;
break;
}
/* next char */
string++;
}
#else /* !WIN_32 */
while (*string == ' ') /* remove leading spaces */
{
strcpy(string, string+1);
}
ii = strlen(string)-1;
while (ii) /* remove trailing spaces */
{
if (isspace(string[ii]))
{
string[ii] = '\0';
ii--;
}
else
break;
}
while (ii) /* scan for last word */
{
if (isspace(string[ii]))
{
/* look for "VO" */
/* the very first word may be "vo"/"viewonly", so
we can edit files of that name */
if ((stricmp (string+ii+1, "vo") == 0) ||
(stricmp (string+ii+1, "viewonly") == 0))
{
view_only = 1;
string[ii] = '\0';
}
break;
}
else
ii--;
}
#endif
return view_only;
} /* parse_input_string */
/* -FF- */
int string_with_eol (char *string)
{
/* check, if there is any <EOL> inside the string */
while (*string)
{
if (perform_test_eol (string, 0)) return 1;
string++;
}
return 0;
} /* string_with_eol */
/* -FF- */
#if HELP_COMMAND_DIRECT
int get_current_string (char FA_HU *buff, long index_1,
long max_ind, char *result)
{
/* Funktion sucht ab buff[index_1] rueckwaerts nach dem start diesen topic, */
/* dann bis max. max_ind nach dem ende des topics, und kopiert alle char */
/* dazwischen nach result. */
/* return value : anzahl der kopierten char, bzw. -1 im fehlerfall */
long ii, i1, i2;
char *abuf;
/* init */
i1 = index_1;
i2 = index_1;
/* search for next word to left */
abuf = &buff[index_1];
for (ii = index_1 ; ii >= 0 ; ii--) /* rueckwaerts ! */
{
i1 = ii;
if (!is_delimiter (*abuf))
break;
abuf--;
}
/* search for start of this word */
abuf = &buff[i1];
for (ii = i1 ; ii >= 0 ; ii--) /* rueckwaerts ! */
{
if (is_delimiter (*abuf))
break;
i1 = ii;
abuf--;
}
/* i1 is 1.st char of word */
/* search for end of this word */
abuf = &buff[i1];
for (ii = i1 ; ii <= max_ind ; ii++) /* incl. EOF !! */
{
i2 = ii;
if (is_delimiter (*abuf))
break;
abuf++;
}
/* i2 is 1.st char behind (!) word */
/* found a valid string ? */
if (i2 <= i1)
{ /* no */
return -1; /* return 'invalid' */
}
else
{ /* yes, convert all characters in between */
abuf = &buff[i1];
i2 = min (i2, (i1 + BUF_256 - strlen (HELP_COMMAND) - 1)); /* limit ! */
for (ii = i1 ; ii < i2 ; ii++)
{
result [ii-i1] = *abuf;
abuf++;
}
result [i2-i1] = '\0'; /* end of string */
return (int)(i2-i1);
}
} /* get_current_string */
#endif
/* -FF- */
/* Modification History */
/* 29.11.92 - file erzeugt */
/* 01.12.92 - comm_find () */
/* 03.12.92 - comm_ctrl_k */
/* 08.12.92 - parse_input_string () */
/* 09.12.92 - string_with_lf () */
/* 10.12.92 - is_german (), lower_upper_umlaut () */
/* 19.12.92 - FA_HU (far / huge) */
/* 21.12.92 - EOL */
/* 30.12.92 - get_current_string () */
/* 04.01.93 - tolower_german () */
/* 28.07.93 - HELP_COMMAND wieder als macro */
/* 28.07.93 - EOL --> EOLN */
/* 28.08.93 - STATIC */
/* 05.09.93 - Find mit Wildcard: '?' */
/* 08.09.93 - Find mit Wildcard: '*' */
/* 10.10.93 - bugfix: S*Y, Find:"*" */
/* 07.11.93 - ^K: nothing found --> err_message () */
/* 29.11.93 - mb_ctype.h */
/* 11.03.94 - comm_find (): verbessertes verhalten bei wildcard-suche */
/* 04.07.94 - WITH_E_DELIMIT */
/* 18.09.94 - long comm_ctrl_k(): #if <--> #else <--> #endif */
#if 0
if (strcmp(&buff[ii], string[0]) == 0) level++;
commands.c(712) : fatal error C1001: Internal Compiler Error
(compiler file '../grammar.c', line 91)
Contact Microsoft Technical Support
if (strcmp(string[0], &buff[ii]) == 0) level++;
alles o.k.
#endif
/* 27.09.94 - type cast(s) wg. compiler warnings (microsoft c 6.0) */
/* 28.09.94 - bugfix: comm_find(): text "r*.c", */
/* search "r*.c", S*Y, not found */
/* 29.09.94 - bugfix: comm_find(): with wild_cards: segmentation violation, */
/* stop searching at end of text buffer */
/* 30.09.94 - is_delimiter(): speed up */
/* 26.01.96 - comm_find_byte() */
/* 31.01.96 - WITH_HEX_FIND */
/* 04.03.99 - corresponding brackets '<' and '>' (e.g. for HTML code) */
/* 22.06.99 - comm_find_byte(): bugfix (unsigned char) for 'H'ex 'F'ind */
/* 14.11.02 - comm_ctrl_k(): #elif */
/* 16.04.03 - comm_ctrl_k(): ada: ^K: if, else, elsif, end if */
/* 16.04.03 - comm_ctrl_k(): ada: ^K: loop, end loop */
/* 24.04.03 - comm_ctrl_k(): ada: ^K: xxxx, end xxxx (any token) */
/* 25.04.03 - comm_ctrl_k(): ada: ^K: ignore token xxxx, if inside comment or string */
/* 28.04.03 - comm_ctrl_k(): correct handling of comments and strings */
/* 07.05.03 - handle nested strings, e.g. "...'..." */
/* 08.05.03 - disable Ada ticks, enable short strings */
/* 11.05.03 - ^K: Ada identifier "xxxx" and "end xxxx" with white space */
/* 12.05.03 - ^K: Ada identifier "xxxx" with delimiter before and behind */
/* 11.09.03 - ^K: Ada "if, else, end if": with delimiter before and behind */
/* 15.09.03 - bugfix: ^K: Ada, nested "if, end if" */
/* 02.11.03 - Visual Basic uses single quote for comments, not strings */
/* 13.03.04 - disp_hnd.c: modifications for CSS (dashes in keywords) */
/* 18.03.04 - disp_hnd.c: bugfix comments inside strings */
/* 19.03.04 - disp_hnd.c: bugfix of previous bugfix */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -