diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-04 23:35:45 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-04 23:35:45 +0200 |
commit | 7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2 (patch) | |
tree | b329db03bae14fca178add9909b78b050345c140 /pdf/pdf_nametree.c | |
parent | efc46353676c27b24f2933dce78305796951a01e (diff) | |
download | mupdf-7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2.tar.xz |
Le Roi est mort, vive le Roi!
The run-together words are dead! Long live the underscores!
The postscript inspired naming convention of using all run-together
words has served us well, but it is now time for more readable code.
In this commit I have also added the sed script, rename.sed, that I used
to convert the source. Use it on your patches and application code.
Diffstat (limited to 'pdf/pdf_nametree.c')
-rw-r--r-- | pdf/pdf_nametree.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/pdf/pdf_nametree.c b/pdf/pdf_nametree.c index 6b2314cd..e2b3e160 100644 --- a/pdf/pdf_nametree.c +++ b/pdf/pdf_nametree.c @@ -2,44 +2,44 @@ #include "mupdf.h" static fz_obj * -pdf_lookupnameimp(fz_obj *node, fz_obj *needle) +pdf_lookup_name_imp(fz_obj *node, fz_obj *needle) { - fz_obj *kids = fz_dictgets(node, "Kids"); - fz_obj *names = fz_dictgets(node, "Names"); + fz_obj *kids = fz_dict_gets(node, "Kids"); + fz_obj *names = fz_dict_gets(node, "Names"); - if (fz_isarray(kids)) + if (fz_is_array(kids)) { int l = 0; - int r = fz_arraylen(kids) - 1; + int r = fz_array_len(kids) - 1; while (l <= r) { int m = (l + r) >> 1; - fz_obj *kid = fz_arrayget(kids, m); - fz_obj *limits = fz_dictgets(kid, "Limits"); - fz_obj *first = fz_arrayget(limits, 0); - fz_obj *last = fz_arrayget(limits, 1); + fz_obj *kid = fz_array_get(kids, m); + fz_obj *limits = fz_dict_gets(kid, "Limits"); + fz_obj *first = fz_array_get(limits, 0); + fz_obj *last = fz_array_get(limits, 1); if (fz_objcmp(needle, first) < 0) r = m - 1; else if (fz_objcmp(needle, last) > 0) l = m + 1; else - return pdf_lookupnameimp(kid, needle); + return pdf_lookup_name_imp(kid, needle); } } - if (fz_isarray(names)) + if (fz_is_array(names)) { int l = 0; - int r = (fz_arraylen(names) / 2) - 1; + int r = (fz_array_len(names) / 2) - 1; while (l <= r) { int m = (l + r) >> 1; int c; - fz_obj *key = fz_arrayget(names, m * 2); - fz_obj *val = fz_arrayget(names, m * 2 + 1); + fz_obj *key = fz_array_get(names, m * 2); + fz_obj *val = fz_array_get(names, m * 2 + 1); c = fz_objcmp(needle, key); if (c < 0) @@ -51,89 +51,89 @@ pdf_lookupnameimp(fz_obj *node, fz_obj *needle) } } - return nil; + return NULL; } fz_obj * -pdf_lookupname(pdf_xref *xref, char *which, fz_obj *needle) +pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle) { - fz_obj *root = fz_dictgets(xref->trailer, "Root"); - fz_obj *names = fz_dictgets(root, "Names"); - fz_obj *tree = fz_dictgets(names, which); - return pdf_lookupnameimp(tree, needle); + fz_obj *root = fz_dict_gets(xref->trailer, "Root"); + fz_obj *names = fz_dict_gets(root, "Names"); + fz_obj *tree = fz_dict_gets(names, which); + return pdf_lookup_name_imp(tree, needle); } fz_obj * -pdf_lookupdest(pdf_xref *xref, fz_obj *needle) +pdf_lookup_dest(pdf_xref *xref, fz_obj *needle) { - fz_obj *root = fz_dictgets(xref->trailer, "Root"); - fz_obj *dests = fz_dictgets(root, "Dests"); - fz_obj *names = fz_dictgets(root, "Names"); - fz_obj *dest = nil; + fz_obj *root = fz_dict_gets(xref->trailer, "Root"); + fz_obj *dests = fz_dict_gets(root, "Dests"); + fz_obj *names = fz_dict_gets(root, "Names"); + fz_obj *dest = NULL; /* PDF 1.1 has destinations in a dictionary */ if (dests) { - if (fz_isname(needle)) - return fz_dictget(dests, needle); + if (fz_is_name(needle)) + return fz_dict_get(dests, needle); else - return fz_dictgets(dests, fz_tostrbuf(needle)); + return fz_dict_gets(dests, fz_to_str_buf(needle)); } /* PDF 1.2 has destinations in a name tree */ if (names && !dest) { - fz_obj *tree = fz_dictgets(names, "Dests"); - return pdf_lookupnameimp(tree, needle); + fz_obj *tree = fz_dict_gets(names, "Dests"); + return pdf_lookup_name_imp(tree, needle); } - return nil; + return NULL; } static void -pdf_loadnametreeimp(fz_obj *dict, pdf_xref *xref, fz_obj *node) +pdf_load_name_tree_imp(fz_obj *dict, pdf_xref *xref, fz_obj *node) { - fz_obj *kids = fz_dictgets(node, "Kids"); - fz_obj *names = fz_dictgets(node, "Names"); + fz_obj *kids = fz_dict_gets(node, "Kids"); + fz_obj *names = fz_dict_gets(node, "Names"); int i; if (kids) { - for (i = 0; i < fz_arraylen(kids); i++) - pdf_loadnametreeimp(dict, xref, fz_arrayget(kids, i)); + for (i = 0; i < fz_array_len(kids); i++) + pdf_load_name_tree_imp(dict, xref, fz_array_get(kids, i)); } if (names) { - for (i = 0; i + 1 < fz_arraylen(names); i += 2) + for (i = 0; i + 1 < fz_array_len(names); i += 2) { - fz_obj *key = fz_arrayget(names, i); - fz_obj *val = fz_arrayget(names, i + 1); - if (fz_isstring(key)) + fz_obj *key = fz_array_get(names, i); + fz_obj *val = fz_array_get(names, i + 1); + if (fz_is_string(key)) { - key = pdf_toutf8name(key); - fz_dictput(dict, key, val); - fz_dropobj(key); + key = pdf_to_utf8_name(key); + fz_dict_put(dict, key, val); + fz_drop_obj(key); } - else if (fz_isname(key)) + else if (fz_is_name(key)) { - fz_dictput(dict, key, val); + fz_dict_put(dict, key, val); } } } } fz_obj * -pdf_loadnametree(pdf_xref *xref, char *which) +pdf_load_name_tree(pdf_xref *xref, char *which) { - fz_obj *root = fz_dictgets(xref->trailer, "Root"); - fz_obj *names = fz_dictgets(root, "Names"); - fz_obj *tree = fz_dictgets(names, which); - if (fz_isdict(tree)) + fz_obj *root = fz_dict_gets(xref->trailer, "Root"); + fz_obj *names = fz_dict_gets(root, "Names"); + fz_obj *tree = fz_dict_gets(names, which); + if (fz_is_dict(tree)) { - fz_obj *dict = fz_newdict(100); - pdf_loadnametreeimp(dict, xref, tree); + fz_obj *dict = fz_new_dict(100); + pdf_load_name_tree_imp(dict, xref, tree); return dict; } - return nil; + return NULL; } |