Lines Matching +full:write +full:- +full:output
1 #!/usr/bin/python -u
6 # I, however, take full credit for any bugs, errors or difficulties :-)
25 # to generate single-byte lookup tables, or inline comparisons
41 ret.append((pos, e-1)) # append range tuple to list
48 # before a 256-byte lookup table is produced. If there are less than this
52 # dictionary of functions, key=name, element contains char-map and range-list
64 # The lines in the .def file have three types:-
78 # split line into space-separated fields, then split on type
96 print "name '%s' already present - may give" \
143 # split the range into it's first-val, last-val
161 # common path - 'currange' has the range, now take care of it
162 # We split on single-byte values vs. multibyte
163 if currange[1] < 0x100: # single-byte
170 else: # multi-byte
182 # enter the output phase, where we generate the two files chvalid.c and'
185 # To do this, we first output the 'static' data (heading, fixed
186 # definitions, etc.), then output the 'dynamic' data (the results
187 # of the above processing), and finally output closing 'static' data
201 output = open("chvalid.c", "w") variable
208 header.write(
266 output.write(
285 * single-byte character is within the specified group. Each table
294 # Now output the generated data.
297 # still not as fast as a sequence of inline compares. So, if the single-byte
298 # portion of a range has a "small" number of ranges, we output a macro for inline
299 # compares, otherwise we output a 256-byte table and a macro to use it.
303 fkeys.sort() # Put some order to our output
307 # First we convert the specified single-byte values into a group of ranges.
315 header.write("XMLPUBVAR const unsigned char %s_tab[256];\n" % f)
316 header.write("""
324 header.write("#define %s_ch(c)\t(%s_tab[(c)])\n" % (f, f))
326 # write the constant data to the code file
327 output.write("const unsigned char %s_tab[256] = {\n" % f)
332 output.write(pline + "\n")
334 output.write(pline + " 0x%02x };\n\n" % Functs[f][0][255])
337 # first another little optimisation - if space is present,
346 header.write("""
354 # okay, I'm tired of the messy lineup - let's automate it!
357 ntab = 4 - (len(pline)) / 8
369 if rg[0] == rg[1]: # single value - check equal
379 header.write(pline)
381 header.write("""
390 ntab = 4 - (len(pline)) / 8
396 header.write(pline + just + "(((c) < 0x100) ? \\\n\t\t\t\t ")
398 header.write("%s_ch((c)) :" % f)
400 header.write("0 :")
405 header.write(" 0)\n\n")
408 header.write(" \\\n\t\t\t\t xmlCharInRange((c), &%sGroup))\n\n" % f)
417 if rg[0] == rg[1]: # single value - check equal
423 header.write(pline)
427 header.write("XMLPUBVAR const xmlChRangeGroup %sGroup;\n" % f)
448 output.write(pline + "\n")
454 output.write(pline + "};\n")
460 output.write(pline + "\n")
463 output.write(pline + "};\n") # finish off last group
475 output.write(pline + "};\n\n")
477 output.write(
497 if (rptr->nbShortRange == 0)
500 high = rptr->nbShortRange - 1;
501 sptr = rptr->shortRange;
505 high = mid - 1;
515 if (rptr->nbLongRange == 0) {
519 high = rptr->nbLongRange - 1;
520 lptr = rptr->longRange;
524 high = mid - 1;
543 output.write("""
551 output.write(" * Use %s_ch or %sQ instead" % (f, f))
553 output.write(" * Use %sQ instead" % f)
554 output.write("""
559 output.write("int\n%s(unsigned int ch) {\n return(%sQ(ch));\n}\n\n" % (f,f))
560 header.write("XMLPUBFUN int XMLCALL\n\t\t%s(unsigned int ch);\n" % f);
562 # Run complete - write trailers and close the output files
565 header.write("""
574 output.write("""#define bottom_chvalid
577 output.close()