vte r2203 - in trunk: . src
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: vte r2203 - in trunk: . src
- Date: Wed, 26 Nov 2008 20:03:30 +0000 (UTC)
Author: behdad
Date: Wed Nov 26 20:03:30 2008
New Revision: 2203
URL: http://svn.gnome.org/viewvc/vte?rev=2203&view=rev
Log:
2008-11-26 Behdad Esfahbod <behdad gnome org>
* src/Makefile.am:
* src/vteseq-2.c (vteseq_2_hash), (vteseq_2_lookup):
* src/vteseq-n.c (vteseq_n_lookup):
* src/vteseq.c (_vte_sequence_get_handler):
Revert previous commit, fix NULL dereference that it was trying to
fix, and make lookup functions inline.
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/vteseq-2.c
trunk/src/vteseq-n.c
trunk/src/vteseq.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Nov 26 20:03:30 2008
@@ -31,11 +31,6 @@
unitable.JIS0212 \
unitable.KSX1001
-# gperf - files need to be modified afterwards
-# In particular:
-# 1. The lookup needs to return the VteTerminalSequenceHandler, or NULL.
-# 2. The functions need to be declared static.
-# 3. For vtese-2, the strlen is known so remove the redudant parameter.
gperf: vteseq-2.gperf vteseq-n.gperf
gperf vteseq-2.gperf -m 100 > vteseq-2.c
gperf vteseq-n.gperf -m 100 > vteseq-n.c
Modified: trunk/src/vteseq-2.c
==============================================================================
--- trunk/src/vteseq-2.c (original)
+++ trunk/src/vteseq-2.c Wed Nov 26 20:03:30 2008
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -m 100 -C vteseq-2.gperf */
+/* Command-line: gperf -m 100 vteseq-2.gperf */
/* Computed positions: -k'1-2' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -45,7 +45,7 @@
#endif
#endif
static unsigned int
-vteseq_2_hash (register const char *str)
+vteseq_2_hash (register const char *str, register unsigned int len)
{
static const unsigned short asso_values[] =
{
@@ -77,7 +77,7 @@
361, 361, 361, 361, 361, 361, 361, 361, 361, 361,
361, 361, 361, 361, 361, 361, 361, 361, 361, 361
};
- return 2 + asso_values[(unsigned char)str[1]+6] + asso_values[(unsigned char)str[0]+14];
+ return len + asso_values[(unsigned char)str[1]+6] + asso_values[(unsigned char)str[0]+14];
}
#ifdef __GNUC__
@@ -86,12 +86,14 @@
__attribute__ ((__gnu_inline__))
#endif
#endif
-static VteTerminalSequenceHandler
-vteseq_2_lookup (register const char *str)
+const struct vteseq_2_struct *
+vteseq_2_lookup (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 221,
+ MIN_WORD_LENGTH = 2,
+ MAX_WORD_LENGTH = 2,
MIN_HASH_VALUE = 2,
MAX_HASH_VALUE = 360
};
@@ -542,8 +544,9 @@
{"LE", vte_sequence_handler_LE}
};
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = vteseq_2_hash (str);
+ register int key = vteseq_2_hash (str, len);
if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
{
@@ -1247,8 +1250,8 @@
{
register const char *s = resword->seq;
- if (str[0] == s[0] && str[1] == s[1] && s[2] == '\0')
- return resword->handler;
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return resword;
}
}
}
Modified: trunk/src/vteseq-n.c
==============================================================================
--- trunk/src/vteseq-n.c (original)
+++ trunk/src/vteseq-n.c Wed Nov 26 20:03:30 2008
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -m 100 -C vteseq-n.gperf */
+/* Command-line: gperf -m 100 vteseq-n.gperf */
/* Computed positions: -k'1,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -212,7 +212,7 @@
__attribute__ ((__gnu_inline__))
#endif
#endif
-static VteTerminalSequenceHandler
+const struct vteseq_n_struct *
vteseq_n_lookup (register const char *str, register unsigned int len)
{
enum
@@ -812,7 +812,7 @@
register const char *s = resword->seq + vteseq_n_pool;
if (*str == *s && !memcmp (str + 1, s + 1, len - 1))
- return resword->handler;
+ return resword;
}
}
}
Modified: trunk/src/vteseq.c
==============================================================================
--- trunk/src/vteseq.c (original)
+++ trunk/src/vteseq.c Wed Nov 26 20:03:30 2008
@@ -4000,17 +4000,28 @@
return FALSE;
}
+
/* LOOKUP */
+static inline const struct vteseq_2_struct *
+vteseq_2_lookup (register const char *str, register unsigned int len);
#include"vteseq-2.c"
+
+static inline const struct vteseq_n_struct *
+vteseq_n_lookup (register const char *str, register unsigned int len);
#include"vteseq-n.c"
VteTerminalSequenceHandler
_vte_sequence_get_handler (const char *code)
{
/* all codes at least two characters... */
- if (code[2] == '\0')
- return vteseq_2_lookup ((const char *)code);
- else
- return vteseq_n_lookup ((const char *)code, strlen (code));
+ if (code[2] == '\0') {
+ const struct vteseq_2_struct *seqhandler;
+ seqhandler = vteseq_2_lookup (code, 2);
+ return seqhandler ? seqhandler->handler : NULL;
+ } else {
+ const struct vteseq_n_struct *seqhandler;
+ seqhandler = vteseq_n_lookup (code, strlen (code));
+ return seqhandler ? seqhandler->handler : NULL;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]