summaryrefslogtreecommitdiff
path: root/gtk/compose-parse.py
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2009-10-25 23:46:27 -0400
committerMatthias Clasen <mclasen@redhat.com>2009-10-25 23:46:27 -0400
commit16482f20db0596851f3b43cc167df2a464115822 (patch)
tree60ad7d5a251a8813fd586bdde69251a7c2e8df26 /gtk/compose-parse.py
parent4c26d99d3e34e4b049aba11250353fc266b8cd3d (diff)
downloadgtk+-16482f20db0596851f3b43cc167df2a464115822.tar.gz
Fixes for the compose-parse.py script
Several fixes by Ray Strode and Peter Hutterer to make compose-parse.py work with the current X.org Compose file.
Diffstat (limited to 'gtk/compose-parse.py')
-rwxr-xr-xgtk/compose-parse.py47
1 files changed, 39 insertions, 8 deletions
diff --git a/gtk/compose-parse.py b/gtk/compose-parse.py
index dfa94925fd..2aa13569b9 100755
--- a/gtk/compose-parse.py
+++ b/gtk/compose-parse.py
@@ -425,30 +425,61 @@ except:
""" Look if there is a lookaside (supplementary) compose file in the current
directory, and if so, open, then merge with upstream Compose file.
"""
+xorg_compose_sequences_raw = []
+for seq in composefile.readlines():
+ xorg_compose_sequences_raw.append(seq)
+
try:
composefile_lookaside = open(FILENAME_COMPOSE_SUPPLEMENTARY, 'r')
+ for seq in composefile_lookaside.readlines():
+ xorg_compose_sequences_raw.append(seq)
except IOError, (errno, strerror):
- if not opt_quiet:
+ if opt_verbose:
print "I/O error(%s): %s" % (errno, strerror)
print "Did not find lookaside compose file. Continuing..."
except:
print "Unexpected error: ", sys.exc_info()[0]
sys.exit(-1)
-xorg_compose_sequences_raw = []
-for seq in composefile.readlines():
- xorg_compose_sequences_raw.append(seq)
-for seq in composefile_lookaside.readlines():
- xorg_compose_sequences_raw.append(seq)
-
""" Parse the compose file in xorg_compose_sequences"""
xorg_compose_sequences = []
xorg_compose_sequences_algorithmic = []
linenum_compose = 0
+comment_nest_depth = 0
for line in xorg_compose_sequences_raw:
linenum_compose += 1
line = line.strip()
- if line is "" or match("^XCOMM", line) or match("^#", line):
+ if match("^XCOMM", line) or match("^#", line):
+ continue
+
+ line = sub(r"\/\*([^\*]*|[\*][^/])\*\/", "", line)
+
+ comment_start = line.find("/*")
+
+ if comment_start >= 0:
+ if comment_nest_depth == 0:
+ line = line[:comment_start]
+ else:
+ line = ""
+
+ comment_nest_depth += 1
+ else:
+ comment_end = line.find("*/")
+
+ if comment_end >= 0:
+ comment_nest_depth -= 1
+
+ if comment_nest_depth < 0:
+ print "Invalid comment %(linenum_compose)d in %(filename)s: \
+ Closing '*/' without opening '/*'" % { "linenum_compose": linenum_compose, "filename": filename_compose }
+ exit(-1)
+
+ if comment_nest_depth > 0:
+ line = ""
+ else:
+ line = line[comment_end + 2:]
+
+ if line is "":
continue
#line = line[:-1]