|
From: Hans-Bernhard B. <br...@us...> - 2001-04-30 15:45:43
|
Update of /cvsroot/cscope/cscope/src
In directory usw-pr-cvs1:/tmp/cvs-serv12801/src
Modified Files:
crossref.c find.c main.c global.h
Log Message:
Bugfix and encapsulate dicode compression code
Index: crossref.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/crossref.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** crossref.c 2000/10/09 19:33:34 1.6
--- crossref.c 2001/04/30 15:45:40 1.7
***************
*** 80,84 ****
static struct symbol *symbol;
! void putcrossref(void);
static void savesymbol(int token, int num);
--- 80,84 ----
static struct symbol *symbol;
! static void putcrossref(void);
static void savesymbol(int token, int num);
***************
*** 209,217 ****
/* output the symbols and source line */
! void
putcrossref(void)
{
int i, j;
! unsigned c;
BOOL blank; /* blank indicator */
int symput = 0; /* symbols output */
--- 209,217 ----
/* output the symbols and source line */
! static void
putcrossref(void)
{
int i, j;
! unsigned char c;
BOOL blank; /* blank indicator */
int symput = 0; /* symbols output */
***************
*** 263,270 ****
}
else {
! /* check for compressed blanks */
if (blank == YES) {
if (dicode2[c]) {
! c = (0200 - 2) + dicode1[' '] + dicode2[c];
}
else {
--- 263,270 ----
}
else {
! /* check for compressed blanks */
if (blank == YES) {
if (dicode2[c]) {
! c = DICODE_COMPRESS(' ', c);
}
else {
***************
*** 273,279 ****
}
/* compress digraphs */
! else if (dicode1[c] && (j = dicode2[(unsigned) yytext[i + 1]]) != 0 &&
! symput < symbols && i + 1 != symbol[symput].first) {
! c = (0200 - 2) + dicode1[c] + j;
++i;
}
--- 273,281 ----
}
/* compress digraphs */
! else if (IS_A_DICODE(c, yytext[i + 1])
! && symput < symbols
! && i + 1 != symbol[symput].first
! ) {
! c = DICODE_COMPRESS(c, yytext[i + 1]);
++i;
}
***************
*** 415,428 ****
writestring(char *s)
{
! unsigned c;
int i;
/* compress digraphs */
for (i = 0; (c = s[i]) != '\0'; ++i) {
! if (dicode1[c] && dicode2[(unsigned) s[i + 1]]) {
! c = (0200 - 2) + dicode1[c] + dicode2[(unsigned) s[i + 1]];
++i;
}
! dbputc((int) c);
}
}
--- 417,432 ----
writestring(char *s)
{
! unsigned char c;
int i;
/* compress digraphs */
for (i = 0; (c = s[i]) != '\0'; ++i) {
! if (/* dicode1[c] && dicode2[(unsigned char) s[i + 1]] */
! IS_A_DICODE(c, s[i + 1])) {
! /* c = (0200 - 2) + dicode1[c] + dicode2[(unsigned char) s[i + 1]]; */
! c = DICODE_COMPRESS(c, s[i + 1]);
++i;
}
! dbputc(c);
}
}
Index: find.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/find.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** find.c 2001/04/26 16:21:33 1.10
--- find.c 2001/04/30 15:45:40 1.11
***************
*** 586,590 ****
int i;
char *s;
! unsigned c;
/* HBB: be nice: free regexp before allocating a new one */
--- 586,590 ----
int i;
char *s;
! unsigned char c; /* HBB 20010427: changed uint to uchar */
/* HBB: be nice: free regexp before allocating a new one */
***************
*** 675,680 ****
s = cpattern;
for (i = 0; (c = pattern[i]) != '\0'; ++i) {
! if (dicode1[c] && dicode2[(unsigned) pattern[i + 1]]) {
! c = (0200 - 2) + dicode1[c] + dicode2[(unsigned) pattern[i + 1]];
++i;
}
--- 675,680 ----
s = cpattern;
for (i = 0; (c = pattern[i]) != '\0'; ++i) {
! if (IS_A_DICODE(c, pattern[i + 1])) {
! c = DICODE_COMPRESS(c, pattern[i + 1]);
++i;
}
Index: main.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/main.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** main.c 2001/03/29 15:03:55 1.18
--- main.c 2001/04/30 15:45:40 1.19
***************
*** 750,757 ****
if (compress == YES) {
for (i = 0; i < 16; ++i) {
! dicode1[(unsigned) (dichar1[i])] = i * 8 + 1;
}
for (i = 0; i < 8; ++i) {
! dicode2[(unsigned) (dichar2[i])] = i + 1;
}
}
--- 750,757 ----
if (compress == YES) {
for (i = 0; i < 16; ++i) {
! dicode1[(unsigned char) (dichar1[i])] = i * 8 + 1;
}
for (i = 0; i < 8; ++i) {
! dicode2[(unsigned char) (dichar2[i])] = i + 1;
}
}
Index: global.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/global.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** global.h 2001/03/27 14:09:19 1.13
--- global.h 2001/04/30 15:45:40 1.14
***************
*** 93,96 ****
--- 93,105 ----
extern char dicode2[]; /* digraph second character code */
+ /* and some macros to help using dicodes: */
+ /* Check if a given pair of chars is compressable as a dicode: */
+ #define IS_A_DICODE(inchar1, inchar2) \
+ (dicode1[(unsigned char)(inchar1)] && dicode2[(unsigned char)(inchar2)])
+ /* Combine the pair into a dicode */
+ #define DICODE_COMPRESS(inchar1, inchar2) \
+ ((0200 - 2) + dicode1[(unsigned char)(inchar1)] \
+ + dicode2[(unsigned char)(inchar2)])
+
/* main.c global data */
extern char *editor, *home, *shell, *lineflag; /* environment variables */
|