File: biblook-readline-2.9.patch

package info (click to toggle)
bibindex 2.9-7
  • links: PTS
  • area: main
  • in suites: potato
  • size: 212 kB
  • ctags: 312
  • sloc: ansic: 2,770; makefile: 171
file content (127 lines) | stat: -rw-r--r-- 3,287 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Only in bibindex-2.9: .debian-bibindex.prcs_aux
diff -r -u bibindex-2.9-orig/Makefile bibindex-2.9/Makefile
--- bibindex-2.9-orig/Makefile	Tue Jan 31 21:15:22 1995
+++ bibindex-2.9/Makefile	Wed Oct 21 15:23:36 1998
@@ -98,7 +98,7 @@
 CFLAGS		= $(DEFINES) $(OPT)	## most cases
 
 GCCFLAGS	= -Wall -Wshadow -Wcast-qual -Wpointer-arith \
-		  -Wwrite-strings
+		  -Wwrite-strings -O2
 
 COL		= col -b
 
@@ -106,7 +106,7 @@
 
 CP		= /bin/cp
 
-DEFINES		= $(DEF_H_FILES) $(DEF_MAXRESULTS) $(DEF_MORE) 
+DEFINES		= $(DEF_H_FILES) $(DEF_MAXRESULTS) $(DEF_MORE) -DUSE_READLINE
 
 # Pick one of these; see the comments above.
 
@@ -133,6 +133,7 @@
 DEF_MORE	= -DMOREPATH=\"/usr/bin/pg\" -DMORE=\"pg\"
 DEF_MORE	= -DMOREPATH=\"/usr/ucb/more\" -DMORE=\"more\"
 DEF_MORE	= -DMOREPATH=\"/usr/local/bin/less\" -DMORE=\"less\"
+DEF_MORE        = -DMOREPATH=\"/usr/bin/pager\" -DMORE=\"pager\"
 
 # This setting is suitable for ftp.math.utah.edu:
 FTPDIR		= /usr/spool/ftp/pub/tex/bib
@@ -146,7 +147,7 @@
 # Use /usr/lib/debug/malloc.o on Sun systems for malloc debugging
 # with acc, gcc, or CC
 LIBS		= /usr/lib/debug/malloc.o
-LIBS		=
+LIBS		= -lreadline
 
 MANDIR		= $(DEST)/man/man1
 
Only in bibindex-2.9: PROBLEMS
Only in bibindex-2.9: README
Only in bibindex-2.9: bibindex
Only in bibindex-2.9: bibindex.c
Only in bibindex-2.9: bibindex.man
Only in bibindex-2.9: bibindex.o
Only in bibindex-2.9: bibindex.txt
Only in bibindex-2.9: biblook
diff -r -u bibindex-2.9-orig/biblook.c bibindex-2.9/biblook.c
--- bibindex-2.9-orig/biblook.c	Tue Mar 31 02:24:51 1998
+++ bibindex-2.9/biblook.c	Wed Oct 21 15:23:36 1998
@@ -1420,6 +1420,30 @@
     T_And, T_Or, T_Not, T_Semi, T_Return, T_Help
 } Token;
 
+#ifdef USE_READLINE
+/* Strip whitespace from the start and end of STRING.  Return a pointer
+   into STRING. */
+char *
+stripwhite (string)
+     char *string;
+{
+  register char *s, *t;
+
+  for (s = string; whitespace (*s); s++)
+    ;
+    
+  if (*s == 0)
+    return (s);
+
+  t = s + strlen (s) - 1;
+  while (t > s && whitespace (*t))
+    t--;
+  *++t = '\0';
+
+  return s;
+}
+#endif
+
 /* ----------------------------------------------------------------- *\
 |  Token GetToken(char *tokenstr)
 |
@@ -1428,6 +1452,9 @@
 Token GetToken(char *tokenstr)
 {
     static char line[256];
+#ifdef USE_READLINE
+    char *r, *s;
+#endif
     static short pos;
     static char neednew = 1;
     short tlen = 0;
@@ -1436,10 +1463,21 @@
 
     if (neednew)
     {
+#ifdef USE_READLINE
+      r = readline("biblook: ");
+      if (!r)
+        return T_Quit;
+      s = stripwhite(r);
+      if (*s)
+	add_history(s);      
+      strncpy(line,r,254);
+      strcat(line,"\n"); /* this trick seems to be necessary */
+      free(r);
+#else
 	(void)printf("biblook: ");
 	if (!fgets(line, 254, stdin))
 	    return T_Quit;
-
+#endif 
 	pos = 0;
 	neednew = 0;
     }
diff -r -u bibindex-2.9-orig/biblook.h bibindex-2.9/biblook.h
--- bibindex-2.9-orig/biblook.h	Tue Mar 31 01:31:04 1998
+++ bibindex-2.9/biblook.h	Wed Oct 21 15:23:36 1998
@@ -232,3 +232,9 @@
 
 /* characters which cannot appear in keywords or abbreviations */
 #define NONKEYCHARS	",\n\t \"#%'()={}"    /* See LaTeX book, p.143 */
+
+#ifdef USE_READLINE
+#  include <readline/readline.h>
+#  include <readline/history.h>
+#endif
+