📄 intlist.e
字号:
if ((len = parse_string(1,".*%([sS]ee ",NULL)) != 0)
{
point += len ; /* go to start of cross-reference */
point += parse_string(1,"also ",NULL) ;
if (parse_string(1,"INT [0-9A-F]",NULL) ||
parse_string(1,"A[XHL] =",NULL)
)
{
point++ ; /* move into reference */
return 1 ;
}
}
return 0 ;
}
/*=============================================================*/
/*=============================================================*/
int grab_int_reference(ref)
char *ref ;
{
int begin, start = point ;
re_search(-1,"[, \t\n]") ; /* backup to start of reference */
if (curchar() == '\n') /* start of line? */
re_search(1,":[ \t]") ; /* skip the SeeAlso: */
else if (character(point-1) == 'T' && character(point-2) == 'N')
point -= 3 ;
else
point++ ; /* back to start of reference */
begin = point ;
re_search(1,"[,\n\"]") ; /* find end of INT-spec */
point-- ;
if (curchar() == '\"') /* extra string at end of INT-spec? */
{
point++ ;
re_search(1,"[\"\n]") ; /* if yes, run to end of line or string */
}
grab(begin,point,ref) ;
point = start ;
return 0 ;
}
/*=============================================================*/
/*=============================================================*/
int parse_int_name(entry_name,id,extra_string)
char *entry_name, *id, *extra_string ;
{
int start = point ;
int i ;
char c, *last ;
for (i = strlen(entry_name)-1 ; i >= 0 ; i--)
entry_name[i] = toupper(entry_name[i]) ;
strcpy(id,"------------") ;
if (strncmp(entry_name,"INT ",4) == 0)
{
id[0] = entry_name[4] ;
id[1] = entry_name[5] ;
entry_name += 6 ;
if (entry_name[0] == '/')
entry_name++ ;
}
else if (to_separator_line(-1))
{
id[0] = character(point+11) ;
id[1] = character(point+12) ;
}
point = start ;
c = entry_name[1] ;
if (entry_name[0] == 'A' && (c == 'X' || c == 'H' || c == 'L'))
{
entry_name += 2 ;
while (entry_name[0] == ' ' || entry_name[0] == '\t')
entry_name++ ;
if (entry_name[0] == '=')
entry_name++ ;
while (entry_name[0] == ' ' || entry_name[0] == '\t')
entry_name++ ;
if (c != 'L')
{
id[2] = entry_name[0] ;
id[3] = entry_name[1] ;
}
if (c == 'X')
{
id[4] = entry_name[2] ;
id[5] = entry_name[3] ;
entry_name += 4 ;
}
else
{
if (c == 'L')
{
id[2] = entry_name[0] ;
id[3] = entry_name[1] ;
}
entry_name += 2 ;
}
if (entry_name[0] == 'H')
entry_name++ ;
if (entry_name[0] == '/')
entry_name++ ;
}
if (index("ABCDES",entry_name[0]) && index("HILPSXF",entry_name[1]))
{
id[6] = entry_name[0] ;
c = id[7] = entry_name[1] ;
entry_name += 2 ;
while (entry_name[0] == ' ' || entry_name[0] == '\t')
entry_name++ ;
if (entry_name[0] == '=')
entry_name++ ;
while (entry_name[0] == ' ' || entry_name[0] == '\t')
entry_name++ ;
id[8] = entry_name[0] ;
id[9] = entry_name[1] ;
if (c != 'H' && c != 'L' && (c != 'F' || entry_name[2] != 'h'))
{
id[10] = entry_name[2] ;
id[11] = entry_name[3] ;
entry_name += 4 ;
}
else
entry_name += 2 ;
if (entry_name[0] == 'H')
entry_name++ ;
if (entry_name[0] == '/')
entry_name++ ;
}
if (entry_name[0] == '\"')
{
entry_name++ ;
strcpy(extra_string,entry_name) ;
last = index(extra_string,'\"') ;
if (last)
*last = '\0' ;
}
else
extra_string[0] = '\0' ;
return 0 ;
}
/*=============================================================*/
/*=============================================================*/
int hex2_to_int(c1,c2)
char c1, c2 ;
{
if (c1 >= '0' && c1 <= '9')
c1 -= '0' ;
else if (c1 >= 'A' && c1 <= 'F')
c1 = c1 - 'A' + 10 ;
else if (c1 >= 'a' && c1 <= 'f')
c1 = c1 - 'a' + 10 ;
else
return -1 ;
if (c2 >= '0' && c2 <= '9')
c2 -= '0' ;
else if (c2 >= 'A' && c2 <= 'F')
c2 = c2 - 'A' + 10 ;
else if (c2 >= 'a' && c2 <= 'f')
c2 = c2 - 'a' + 10 ;
else
return -1 ;
return 16*c1 + c2 ;
}
/*=============================================================*/
/*=============================================================*/
char hex_digit(val)
int val ;
{
if (val < 0)
return '-' ;
else
return (val > 9) ? ('A' + val - 10) : ('0' + val) ;
}
/*=============================================================*/
/*=============================================================*/
int scan_for_entry(entry,extra_str,first_entry)
char *entry, *extra_str ;
int *first_entry ;
{
int bestcount = 0 ;
int bestmatch = -1 ;
if (extra_str) extra_str = 0 ; /* for now, to avoid compiler warning */
*first_entry = 0 ;
/* scan for the first entry for the desired interrupt number */
while (to_separator_line(1))
{
point += 2 ;
if (character(point) == entry[0] && character(point+1) == entry[1])
break ;
nl_forward() ;
}
/* now scan through the entries for the given interrupt number */
while (to_separator_line(1))
{
int i ;
char buf[14] ;
point += 2 ;
grab(point,point+12,buf) ;
if ((buf[0] != entry[0] || buf[1] != entry[1]) &&
(buf[0] != '-' && buf[1] != '-'))
break ; /* ran out of entries... */
for (i = 2 ; i <= 12 ; i++)
{
if (buf[i] != entry[i])
break ;
}
if (i > bestcount)
{
bestcount = i ;
bestmatch = point ;
if (i > 12)
break ; /* found an exact match */
}
nl_forward() ;
}
if (bestmatch == -1)
return 0 ; /* we failed */
else
{
*first_entry = bestmatch ;
point = bestmatch ; /* back to best-matching entry */
nl_forward() ;
return 1 ; /* we were successful */
}
}
/*=============================================================*/
/*=============================================================*/
int goto_entry(entry_name)
char *entry_name ;
{
char int_id[13], extra_string[60] ;
int start = point, first_entry ;
int int_num, curr_int ;
char search_str[22] ;
parse_int_name(entry_name,int_id,extra_string) ;
int_num = hex2_to_int(int_id[0],int_id[1]) ;
if (to_separator_line(-1))
{
if (character(point+11) == '-')
curr_int = -1 ;
else
curr_int = hex2_to_int(character(point+11),character(point+12)) ;
if (int_num <= 0)
point = 0 ; /* go to top of file */
else
{
if (curr_int <= 0)
point = 0 ; /* go to top of file */
strcpy(search_str,"--------.-") ;
search_str[10] = hex_digit((int_num-1) / 16) ;
search_str[11] = hex_digit((int_num-1) % 16) ;
search_str[12] = '\0' ;
if (!re_search( (int_num<=curr_int)?-1:1, search_str))
{
say("%s not found.",entry_name) ;
iter = 1 ;
return 0 ;
}
to_begin_line() ;
}
}
else
point = 0 ;
if (!scan_for_entry(int_id,extra_string,&first_entry))
{
say("%s not found.",entry_name) ;
if (first_entry)
{
mark = start ;
point = first_entry ;
}
else
point = start ;
}
if (has_arg)
iter = 1 ; /* don't search repeatedly */
return 0 ;
}
/*=============================================================*/
/*=============================================================*/
command goto_int() on intlist_tab[FCTRL(12)]
{
char entry_name[60], def_entry[60] ;
int start = point ;
to_begin_line() ;
if (parse_string(1,"SeeAlso: ",NULL) != 0)
{
point += 9 ; /* skip the SeeAlso: */
if (point < start) /* if we were originally to the right of */
point = start ; /* current position, go back to original pos */
grab_int_reference(def_entry) ;
get_strdef(entry_name,"Goto Interrupt",def_entry) ;
}
else if (line_has_see_also())
{
grab_int_reference(def_entry) ;
get_strdef(entry_name,"Goto Interrupt",def_entry) ;
}
else
get_string(entry_name,"Goto Interrupt: ") ;
point = start ;
goto_entry(entry_name) ;
if (has_arg)
iter = 1 ;
}
/*=============================================================*/
/*=============================================================*/
void maybe_append_table_number()
{
if (parse_string(1,".*\t%(Table ",0) == 0)
{
int matchsize ;
/* if the pattern didn't match, there is no table number, */
/* so add it */
to_end_line() ;
matchsize = parse_string(-1,"[ \t]+",0) ;
if (matchsize)
delete(point-matchsize,point) ;
stuff("\t") ;
insert_table_counter() ;
}
}
/*=============================================================*/
/*=============================================================*/
void fix_unnumbered_tables()
{
spot start = alloc_spot(1) ;
*start = point ;
point = 0 ;
while (search(1,"\n\n"))
{
switch(curchar())
{
case 'C':
if (parse_string(1,"Call ") != 0)
{
/* we got Call..., we know it doesn't have a table number */
insert_table_counter() ;
stuff("\n") ;
}
break ;
case 'V':
if (parse_string(1,"Values ") != 0)
{
/* we know this Values... doesn't have a table number */
insert_table_counter() ;
stuff("\n") ;
}
break ;
case 'B':
if (parse_string(1,"Bitfields ",0) == 0)
break ;
nl_forward() ; /* skip to start of next line */
maybe_append_table_number() ;
break ;
case 'F':
if (parse_string(1,"Format ",0) == 0)
break ;
nl_forward() ; /* skip to start of next line */
maybe_append_table_number() ;
break ;
default:
/* not a table header, so ignore it */
break ;
}
}
point = *start ;
free_spot(start) ;
}
/*=============================================================*/
/*=============================================================*/
int *gather_table_numbers(new_numbers)
int *new_numbers ;
{
int tcount[9] ;
char counter[6] ;
int old_number ;
int table_type ;
spot start = alloc_spot(1) ;
save_var case_fold = 0 ;
tcount[0] = tcount[1] = tcount[2] = tcount[3] = tcount[4] = tcount[5] = 0 ;
tcount[6] = tcount[7] = tcount[8] = 0 ;
*start = point ;
point = 0 ;
while (search(1,"(Table "))
{
char *tbl ;
int table_offset ;
grab(point,point+5,counter) ;
tbl = index(table_ID_letters,counter[0]) ;
if (tbl)
table_offset = (tbl-table_ID_letters) ;
else
table_offset = 0 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -