You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mkshort.cc 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. /*
  2. Generate unique short names.
  3. Copyright (C) 2003, 2004, 2005, 2006 Robert Lipe, robertlipe+source@gpsbabel.org
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  15. */
  16. #include "defs.h"
  17. #include "cet.h"
  18. #include "cet_util.h"
  19. #include <ctype.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #define MYNAME "mkshort"
  24. static const char vowels[] = "aeiouAEIOU";
  25. #define DEFAULT_TARGET_LEN 8
  26. static const char* DEFAULT_BADCHARS = "\"$.,'!-";
  27. /*
  28. * Hash table tunings. The reality is that our hash doesn't have to be
  29. * terribly complex; our strings are short (typically 8-20 bytes) and the
  30. * string hash mixes things up enough that strcmp can generally bail on the
  31. * first byte or two for a mismatch.
  32. */
  33. #define PRIME 37
  34. typedef struct {
  35. queue list;
  36. char* orig_shortname;
  37. int conflictctr;
  38. } uniq_shortname;
  39. static struct replacements {
  40. const char* orig;
  41. const char* replacement;
  42. } replacements[] = {
  43. {"zero", "0"},
  44. {"one", "1"},
  45. {"two", "2"},
  46. {"three", "3"},
  47. {"four", "4"},
  48. {"five", "5"},
  49. {"six", "6"},
  50. {"seven", "7"},
  51. {"eight", "8"},
  52. {"nine", "9"},
  53. {NULL, NULL}
  54. };
  55. /*
  56. * We hash all strings as upper case.
  57. */
  58. unsigned int hash_string(const char* key)
  59. {
  60. unsigned int hash = 0;
  61. while (*key) {
  62. hash = ((hash<<5) ^ (hash>>27)) ^ toupper(*key++);
  63. }
  64. hash = hash % PRIME;
  65. return hash;
  66. }
  67. short_handle
  68. #ifdef DEBUG_MEM
  69. MKSHORT_NEW_HANDLE(DEBUG_PARAMS)
  70. #else
  71. mkshort_new_handle()
  72. #endif
  73. {
  74. int i;
  75. mkshort_handle_imp* h = (mkshort_handle_imp*) xxcalloc(sizeof *h, 1, file, line);
  76. for (i = 0; i < PRIME; i++) {
  77. QUEUE_INIT(&h->namelist[i]);
  78. }
  79. h->whitespaceok = 1;
  80. h->badchars = xstrdup(DEFAULT_BADCHARS);
  81. h->target_len = DEFAULT_TARGET_LEN;
  82. h->must_uniq = 1;
  83. h->defname = xstrdup("WPT");
  84. h->is_utf8 = (global_opts.charset == &cet_cs_vec_utf8);
  85. return h;
  86. }
  87. static
  88. uniq_shortname*
  89. is_unique(mkshort_handle_imp* h, char* name)
  90. {
  91. queue* e, *t;
  92. int hash;
  93. hash = hash_string(name);
  94. QUEUE_FOR_EACH(&h->namelist[hash], e, t) {
  95. uniq_shortname* z = (uniq_shortname*) e;
  96. if (0 == case_ignore_strcmp(z->orig_shortname, name)) {
  97. return z;
  98. }
  99. }
  100. return (uniq_shortname*) NULL;
  101. }
  102. static
  103. void
  104. add_to_hashlist(mkshort_handle_imp* h, char* name)
  105. {
  106. int hash = hash_string(name);
  107. uniq_shortname* s = (uniq_shortname*) xcalloc(1, sizeof(uniq_shortname));
  108. s->orig_shortname = xstrdup(name);
  109. ENQUEUE_TAIL(&h->namelist[hash], &s->list);
  110. }
  111. char*
  112. mkshort_add_to_list(mkshort_handle_imp* h, char* name)
  113. {
  114. uniq_shortname* s;
  115. while ((s = is_unique(h, name))) {
  116. int dl;
  117. char tbuf[10];
  118. size_t l = strlen(name);
  119. s->conflictctr++;
  120. dl = sprintf(tbuf, ".%d", s->conflictctr);
  121. if (l + dl < h->target_len) {
  122. name = (char*) xrealloc(name, l + dl + 1);
  123. strcat(name, tbuf);
  124. } else {
  125. strcpy(&name[l-dl], tbuf);
  126. }
  127. }
  128. add_to_hashlist(h, name);
  129. return name;
  130. }
  131. void
  132. mkshort_del_handle(short_handle* h)
  133. {
  134. mkshort_handle_imp* hdr = (mkshort_handle_imp*) *h;
  135. int i;
  136. if (!h || !hdr) {
  137. return;
  138. }
  139. for (i = 0; i < PRIME; i++) {
  140. queue* e, *t;
  141. QUEUE_FOR_EACH(&hdr->namelist[i], e, t) {
  142. uniq_shortname* s = (uniq_shortname*) e;
  143. #if 0
  144. if (global_opts.verbose_status >= 2 && s->conflictctr) {
  145. fprintf(stderr, "%d Output name conflicts: '%s'\n",
  146. s->conflictctr, s->orig_shortname);
  147. }
  148. #endif
  149. dequeue(e);
  150. xfree(s->orig_shortname);
  151. xfree(s);
  152. }
  153. }
  154. /* setshort_badchars(*h, NULL); ! currently setshort_badchars() always allocates something ! */
  155. if (hdr->badchars != NULL) {
  156. xfree(hdr->badchars);
  157. }
  158. setshort_goodchars(*h, NULL);
  159. if (hdr->defname) {
  160. xfree(hdr->defname);
  161. }
  162. xfree(hdr);
  163. *h = NULL;
  164. }
  165. /*
  166. * This is the stuff that makes me ashamed to be a C programmer...
  167. */
  168. static
  169. char*
  170. delete_last_vowel(int start, char* istring, int* replaced)
  171. {
  172. int l;
  173. /*
  174. * Basically impelement strrchr.
  175. */
  176. *replaced = 0;
  177. for (l = strlen(istring); l > start; l--) {
  178. if (strchr(vowels, istring[l-1])) {
  179. char* ostring;
  180. /* If vowel is the first letter of a word, keep it.*/
  181. if (istring[l-2] == ' ') {
  182. continue;
  183. }
  184. ostring = xstrdup(istring);
  185. strncpy(&ostring[l-1], &istring[l], 1+strlen(istring)-l);
  186. ostring[strlen(istring)-1] = 0;
  187. *replaced = 1;
  188. strcpy(istring, ostring);
  189. xfree(ostring);
  190. break;
  191. }
  192. }
  193. return istring;
  194. }
  195. /*
  196. * Open the slippery slope of literal replacement. Right now, replacements
  197. * are made only at the end of the string.
  198. */
  199. void
  200. replace_constants(char* s)
  201. {
  202. struct replacements* r;
  203. int origslen = strlen(s);
  204. for (r = replacements; r->orig; r++) {
  205. int rl = strlen(r->orig);
  206. /*
  207. * If word is in replacement list and preceeded by a
  208. * space, replace it.
  209. */
  210. if ((origslen - rl > 1) &&
  211. (0 == case_ignore_strcmp(r->orig, &s[origslen - rl])) &&
  212. (s[origslen - rl - 1] == ' ')) {
  213. strcpy(&s[origslen - rl], r->replacement);
  214. return ;
  215. }
  216. }
  217. }
  218. /*
  219. * Externally callable function to set the max length of the
  220. * strings returned by mkshort(). 0 resets to default.
  221. */
  222. void
  223. setshort_length(short_handle h, int l)
  224. {
  225. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  226. if (l == 0) {
  227. hdl->target_len = DEFAULT_TARGET_LEN;
  228. } else {
  229. hdl->target_len = l;
  230. }
  231. }
  232. /*
  233. * Call with L nonzero if whitespace in the generated shortname is wanted.
  234. */
  235. void
  236. setshort_whitespace_ok(short_handle h, int l)
  237. {
  238. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  239. hdl->whitespaceok = l;
  240. }
  241. /*
  242. * Call with L nonzero if multiple consecutive whitespace in the
  243. * generated shortname is wanted.
  244. */
  245. void
  246. setshort_repeating_whitespace_ok(short_handle h, int l)
  247. {
  248. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  249. hdl->repeating_whitespaceok = l;
  250. }
  251. /*
  252. * Set default name given to a waypoint if no valid is possible
  253. * because it was filtered by charsets or null or whatever.
  254. */
  255. void
  256. setshort_defname(short_handle h, const char* s)
  257. {
  258. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  259. if (s == NULL) {
  260. fatal("setshort_defname called without a valid name.");
  261. }
  262. if (hdl->defname != NULL) {
  263. xfree(hdl->defname);
  264. }
  265. hdl->defname = xstrdup(s);
  266. }
  267. /*
  268. * Externally callable function to set the string of characters
  269. * that must never appear in a string returned by mkshort. NULL
  270. * resets to default.
  271. */
  272. void
  273. setshort_badchars(short_handle h, const char* s)
  274. {
  275. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  276. if ((hdl->badchars != NULL)) {
  277. xfree(hdl->badchars);
  278. }
  279. hdl->badchars = xstrdup(s ? s : DEFAULT_BADCHARS);
  280. }
  281. /*
  282. * Only characters that appear in *s are "whitelisted" to appear
  283. * in generated names.
  284. */
  285. void
  286. setshort_goodchars(short_handle h, const char* s)
  287. {
  288. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  289. if (hdl->goodchars != NULL) {
  290. xfree(hdl->goodchars);
  291. }
  292. if (s != NULL) {
  293. hdl->goodchars = xstrdup(s);
  294. } else {
  295. hdl->goodchars = NULL;
  296. }
  297. }
  298. /*
  299. * Call with i non-zero if generated names must be uppercase only.
  300. */
  301. void
  302. setshort_mustupper(short_handle h, int i)
  303. {
  304. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  305. hdl->mustupper = i;
  306. }
  307. /*
  308. * Call with i zero if the generated names don't have to be unique.
  309. * (By default, they are.)
  310. */
  311. void
  312. setshort_mustuniq(short_handle h, int i)
  313. {
  314. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  315. hdl->must_uniq = i;
  316. }
  317. /*
  318. * Declare that actually characters are (or are not) encoded in UTF-8.
  319. */
  320. void
  321. setshort_is_utf8(short_handle h, const int is_utf8)
  322. {
  323. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  324. hdl->is_utf8 = is_utf8;
  325. }
  326. char*
  327. #ifdef DEBUG_MEM
  328. MKSHORT(short_handle h, const char* istring, DEBUG_PARAMS)
  329. #else
  330. mkshort(short_handle h, const char* istring)
  331. #endif
  332. {
  333. char* ostring;
  334. char* nstring;
  335. char* tstring;
  336. char* cp;
  337. char* np;
  338. int i, l, replaced;
  339. size_t nlen;
  340. mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
  341. if (hdl->is_utf8) {
  342. ostring = cet_utf8_strdup(istring); /* clean UTF-8 string */
  343. } else {
  344. ostring = xxstrdup(istring, file, line);
  345. }
  346. /*
  347. * A rather horrible special case hack.
  348. * If the target length is "6" and the source length is "7" and
  349. * the first two characters are "GC", we'll assume it's one of the
  350. * the new seven digit geocache numbers and special case whacking
  351. * the 'G' off the front.
  352. */
  353. if ((hdl->target_len == 6) && (strlen(ostring) == 7) &&
  354. (ostring[0] == 'G') && (ostring[1] == 'C')) {
  355. memmove(&ostring[0], &ostring[1], strlen(ostring));
  356. }
  357. /*
  358. * Whack leading "[Tt]he",
  359. */
  360. if ((strlen(ostring) > hdl->target_len + 4) &&
  361. (strncmp(ostring, "The ", 4) == 0 ||
  362. strncmp(ostring, "the ", 4) == 0)) {
  363. nstring = xxstrdup(ostring + 4, file, line);
  364. xfree(ostring);
  365. ostring = nstring;
  366. }
  367. /* Eliminate leading whitespace in all cases */
  368. while (ostring[0] && isspace(ostring[0])) {
  369. /* If orig string has N bytes, we want to copy N-1 bytes
  370. * of the string itself plus the string terminator (which
  371. * matters if the string consists of nothing but spaces)
  372. */
  373. memmove(&ostring[0], &ostring[1], strlen(ostring));
  374. }
  375. if (!hdl->whitespaceok) {
  376. /*
  377. * Eliminate Whitespace
  378. */
  379. tstring = xxstrdup(ostring, file, line);
  380. l = strlen(tstring);
  381. cp = ostring;
  382. for (i=0; i<l; i++) {
  383. if (!isspace(tstring[i])) {
  384. *cp++ = tstring[i];
  385. }
  386. }
  387. xfree(tstring);
  388. *cp = 0;
  389. }
  390. if (hdl->mustupper) {
  391. for (tstring = ostring; *tstring; tstring++) {
  392. *tstring = toupper(*tstring);
  393. }
  394. }
  395. /* Before we do any of the vowel or character removal, look for
  396. * constants to replace.
  397. */
  398. replace_constants(ostring);
  399. /*
  400. * Eliminate chars on the blacklist.
  401. */
  402. tstring = xxstrdup(ostring, file, line);
  403. l = strlen(tstring);
  404. cp = ostring;
  405. for (i=0; i<l; i++) {
  406. if (strchr(hdl->badchars, tstring[i])) {
  407. continue;
  408. }
  409. if (hdl->goodchars && (!strchr(hdl->goodchars, tstring[i]))) {
  410. continue;
  411. }
  412. // FIXME(robertl): we need a way to not return partial UTF-8, but this isn't it.
  413. // if (!isascii(tstring[i]))
  414. // continue;
  415. *cp++ = tstring[i];
  416. }
  417. *cp = 0;
  418. xfree(tstring);
  419. /*
  420. * Eliminate repeated whitespace. This can only shorten the string
  421. * so we do it in place.
  422. */
  423. if (!hdl->repeating_whitespaceok) {
  424. for (i = 0; i < l-1; i++) {
  425. if (ostring[i] == ' ' && ostring[i+1] == ' ') {
  426. memmove(&ostring[i], &ostring[i+1], l-i);
  427. }
  428. }
  429. }
  430. /*
  431. * Toss vowels to approach target length, but don't toss them
  432. * if we don't have to. We always keep the leading two letters
  433. * to preserve leading vowels and some semblance of pronouncability.
  434. *
  435. * FIXME: There's a boundary case here where we're too aggressive.
  436. * If the target length is "6" we will shorten "Trolley" to "Trlly",
  437. * when we really don't have to. We should throw away one vowel, not
  438. * both.
  439. */
  440. /*
  441. * Delete vowels starting from the end. If it fits, quit stomping
  442. * them. If we run out of string, give up.
  443. *
  444. * Skip this test is our target length is arbitrarily considered
  445. * "long" as it turns out a truncated string of full words is easier
  446. * to read than a full string of vowelless words.
  447. *
  448. * It also helps units with speech synthesis.
  449. */
  450. if (hdl->target_len < 15) {
  451. replaced = 1;
  452. } else {
  453. replaced = 0;
  454. }
  455. while (replaced && strlen(ostring) > hdl->target_len) {
  456. ostring = delete_last_vowel(2, ostring, &replaced);
  457. }
  458. /*
  459. * Next to last thing, we look for trailing numbers and try to
  460. * preserve those. This ensures that.
  461. * Walk in the Woods 1.
  462. * Walk in the Woods 2.
  463. */
  464. np = ostring + strlen(ostring);
  465. while ((np != ostring) && *(np-1) && isdigit(*(np-1))) {
  466. np--;
  467. }
  468. nlen = strlen(np);
  469. /*
  470. * Now brutally truncate the resulting string, preserve trailing
  471. * numeric data.
  472. * If the numeric component alone is longer than our target string
  473. * length, use only what'll fit.
  474. */
  475. if (hdl->is_utf8) {
  476. /* ToDo: Keep trailing numeric data as described above! */
  477. if (cet_utf8_strlen(ostring) > hdl->target_len) {
  478. char* tmp = cet_utf8_strndup(ostring, hdl->target_len);
  479. xfree(ostring);
  480. ostring = tmp;
  481. }
  482. } else if ((/*i = */strlen(ostring)) > hdl->target_len) {
  483. char* dp = &ostring[hdl->target_len] - nlen;
  484. if (dp < ostring) {
  485. dp = ostring;
  486. }
  487. memmove(dp, np, nlen);
  488. dp[nlen] = 0;
  489. rtrim(ostring);
  490. }
  491. /*
  492. * If, after all that, we have an empty string, punt and
  493. * let the must_uniq code handle it.
  494. */
  495. if (ostring[0] == '\0') {
  496. xfree(ostring);
  497. ostring = xstrdup(hdl->defname);
  498. }
  499. if (hdl->must_uniq) {
  500. return mkshort_add_to_list(hdl, ostring);
  501. }
  502. return ostring;
  503. }
  504. QString
  505. mkshort(short_handle h, const QString& istring)
  506. {
  507. char* t = mkshort(h, CSTR(istring));
  508. QString r(t);
  509. xfree(t);
  510. return r;
  511. }
  512. /*
  513. * As above, but arg list is a waypoint so we can centralize
  514. * the code that considers the alternate sources.
  515. */
  516. QString
  517. mkshort_from_wpt(short_handle h, const Waypoint* wpt)
  518. {
  519. /* This probably came from a Groundspeak Pocket Query
  520. * so use the 'cache name' instead of the description field
  521. * which contains placer name, diff, terr, and generally way
  522. * more stuff than should be in any one field...
  523. */
  524. if (wpt->gc_data->diff && wpt->gc_data->terr &&
  525. !wpt->notes.isEmpty()) {
  526. return mkshort(h, wpt->notes);
  527. }
  528. if (!wpt->description.isEmpty()) {
  529. return mkshort(h, wpt->description);
  530. }
  531. if (!wpt->notes.isEmpty()) {
  532. return mkshort(h, wpt->notes);
  533. }
  534. /* Should probably never actually happen... */
  535. /* O.K.: But this can happen (waypoints transformed from trackpoints )! */
  536. /* Now we return every time a valid entity." */
  537. return mkshort(h, wpt->shortname);
  538. }
  539. #if 0
  540. char* foo[] = {
  541. "VwthPst# 3700.706N 08627.588W 0000000m View the Past #2 ",
  542. "PilotRoc 3655.270N 08717.173W 0000000m Pilot Rock by CacheAdvance ",
  543. "MrCycsNg 3652.407N 08728.890W 0000000m Mr. Cayces Neighborhood by Ca",
  544. "SOLDIER 3640.691N 08726.660W 0000000m SOLDIER&#8217;S TRIBUTE ",
  545. "ZOOMZOOM 3636.659N 08721.793W 0000000m ZOOM ZOOM ZOOM by Feros Family",
  546. "SOCLOSEB 3636.494N 08722.086W 0000000m SO CLOSE BUT YET by Kyle of Fe",
  547. "InSrchfS 3636.363N 08636.363W 0000000m In Search of Steam by BigHank ",
  548. "RdBlngSp 3632.119N 08550.956W 0000000m Red Boiling Springs by Firedog",
  549. "HelngWtr 3631.729N 08550.481W 0000000m Healing Waters by FiredogPotte",
  550. "AHHtheVi 3629.020N 08533.891W 0000000m ogPotter ",
  551. "LstCrkCc 3628.167N 08801.656W 0000000m Lost Creek Cache by Paul Kathy",
  552. "DlvrncTr 3626.412N 08729.249W 0000000m Deliverance Train by Team Skay",
  553. "FrQrtrRn 3438.502N 08646.926W 0000000m Four Quarter Rendezvous by Zay",
  554. "Jstlttlc 3620.647N 08814.298W 0000000m Just a little cache by Paul Ka",
  555. "BrryPtch 3618.786N 08616.344W 0000000m Berry Patch Cache by White Dog",
  556. "AStrllDw 3342.752N 08630.829W 0000000m A Stroll Down Memory Lane by t",
  557. "QunfTnns 3606.413N 08651.962W 0000000m Queen of Tennessee by A182pilo",
  558. "GoneFish 3618.199N 08655.171W 0000000m Gone Fishin' by White Dog Pack",
  559. "GrnwysFn 3610.942N 08642.061W 0000000m Greenways Fence by Ukulele And",
  560. "AStnsThr 3611.240N 08638.324W 0000000m A Stone's Throw by Murrcat & S",
  561. "Nashvlls 3617.112N 08642.359W 0000000m Nashville's Zoo by White Dog P",
  562. "BltzMcr4 3517.127N 08622.211W 0000000m Blitz Micro Number 4 by IHTFP ",
  563. "NkdnthWn 3437.145N 08651.693W 0000000m Naked in the Wind by Zaybex ",
  564. "ANcPlctR 3603.389N 08654.418W 0000000m A Nice Place to Rest by JoGPS ",
  565. "welcomtT 3638.155N 08720.130W 0000000m welcome to TN by Raf of the se",
  566. "welcomtK 3638.956N 08721.011W 0000000m welcome to KY by raf of the se",
  567. "BltzMcr5 3506.191N 08634.277W 0000000m Blitz Micro Number 5 by IHTFP ",
  568. "JmsFmlyG 3615.887N 08649.846W 0000000m James Family Grocery by White ",
  569. "seekngrf 3629.262N 08742.333W 0000000m seekeing refuge by raf of the ",
  570. "SecrtFll 3614.927N 08534.180W 0000000m Secret Falls ",
  571. "ApstlcTh 3613.870N 08645.108W 0000000m Apostolic Thistle Walk by Jame",
  572. "WllIllBD 3609.258N 08637.268W 0000000m Well....I'll Be \"Dammed\" byi",
  573. "BettysBt 3608.857N 08550.564W 0000000m Betty's Booty by White Dog Pac",
  574. "SmthngSm 3439.748N 08643.522W 0000000m Something Smells Fishy by Zayb",
  575. "RckyRd(C 3605.315N 08549.326W 0000000m Rocky Road (Center Hill Lake) ",
  576. "Brdwtchr 3436.605N 08651.243W 0000000m Birdwatcher's Dream by Zaybex ",
  577. "JcksnsHl 3605.185N 08619.439W 0000000m Jackson's Halls by White Dog P",
  578. "FrgttnP2 3509.599N 08633.282W 0000000m Forgotten Park 2 by mdawg & mu",
  579. "SOLDIERS 3640.691N 08726.660W 0000000m SOLDIERS TRIBUTE by Feros Fami",
  580. "EndofRop 3433.820N 08650.460W 0000000m End of Rope by Big Rock ",
  581. "VwthPst1 3659.263N 08627.114W 0000000m View the Past #1 by wkgraham ",
  582. "VwthPst2 3700.706N 08627.588W 0000000m View the Past #2 by wkgraham ",
  583. "Trash#8 3603.102N 08655.144W 0000000m Cache In Trash Out # 8 ",
  584. "SlwwwwCc 3602.543N 08535.953W 0000000m Sloowwww Cache by Tntcacher ",
  585. "Leavttbv 3602.514N 08638.686W 0000000m Leave it to beaver by A182pilo",
  586. "WhrrthHr 3436.594N 08654.759W 0000000m Where are the Horses? by Zaybe",
  587. "ButtonCc 3433.401N 08645.294W 0000000m Button Cache by Zaybex ",
  588. "MrcsLbrr 3436.842N 08655.972W 0000000m Marco's Library by Marco ",
  589. "Octopus 3526.743N 08534.757W 0000000m Octopus by White Dog Pack ",
  590. "WtrFllsV 3544.140N 08527.861W 0000000m Water Falls Valley by Cave Rat",
  591. "DeddrpPn 3448.126N 08719.696W 0000000m Dead-drop Pink by Marco ",
  592. "JWhlrRvr 3448.157N 08719.914W 0000000m Joe Wheeler River Walk by Marc",
  593. "CvSprngs 3432.797N 08651.084W 0000000m Cave Springs Cache by Marco.. ",
  594. "CnyFrkOv 3550.876N 08518.446W 0000000m Fork Overlook ",
  595. "SheepsCa 3550.527N 08519.480W 0000000m Sheep's Cave ",
  596. "VrgnFlls 3550.308N 08519.904W 0000000m Virgin Falls Cache ",
  597. "ShrtctVr 3550.170N 08519.590W 0000000m Shortcut Virtual ",
  598. "KlylFlls 3549.105N 08539.814W 0000000m Klaylee Falls Cache by pattytr",
  599. "FshngfrB 3548.923N 08538.558W 0000000m BADGER by M&Mk ",
  600. "TpfthHll 3548.808N 08601.722W 0000000m Top of the Hill Pet Cache by M",
  601. "TwnFllsC 3548.560N 08537.996W 0000000m Twin Falls Cache by SLCREW a",
  602. "WtchsCst 3548.197N 08537.673W 0000000m Witch's Castle Keys by SLCREW ",
  603. "ThatCave 3544.901N 08522.854W 0000000m That Cave by JaDan150 and AprJ",
  604. "BssltwnW 3541.174N 08801.489W 0000000m Busseltown Wildlife Refuge by ",
  605. "Riverfrn 3540.968N 08546.995W 0000000m Riverfront by SLCREW and M&M",
  606. "Basement 3540.086N 08521.304W 0000000m The Basement ",
  607. "EfflTwrC 3617.132N 08818.371W 0000000m Eiffel Tower Cache by Dick Wan",
  608. "KeyholeC 3544.562N 08524.098W 0000000m Keyhole Cave by Cave Rat ",
  609. "(MC^2)Mn 3444.990N 08630.218W 0000000m (MC^2) Monte Sano Cuts Cache b",
  610. "WildctCc 3636.823N 08808.087W 0000000m Wildcat Cache by The Storm ",
  611. "NAlbm/Tn 3444.365N 08632.688W 0000000m N. Alabama / Tennessee Valley ",
  612. "CalebsCa 3444.215N 08633.103W 0000000m Caleb's Cave by Papaw and Cale",
  613. "MntSnPrs 3444.201N 08632.591W 0000000m Monte Sano Preserve by Evan & ",
  614. "FltRckFl 3444.475N 08629.958W 0000000m Flat Rock Falls Cache by Jason",
  615. "PanormCc 3443.961N 08631.638W 0000000m The Panorama Cache by IHTFP an",
  616. "TnnssScv 3602.861N 08652.751W 0000000m Tennessee Scavenger Hunt Cache",
  617. "Geocache 3435.209N 08655.968W 0000000m Geocache by Papaw & Caleb ",
  618. "Skellig 3444.100N 08656.566W 0000000m Skellig by Zaybex ",
  619. "Deceptio 3433.450N 08655.711W 0000000m Deception by Papaw and Caleb ",
  620. "AwlknthD 3433.310N 08655.635W 0000000m A walk in the Desert by Papa",
  621. "MiniMsQs 3558.934N 08650.674W 0000000m Mini Me's Quest by CrotalusRex",
  622. "BakrsBlf 3541.891N 08717.300W 0000000m Bakers Bluff by Flower Child &",
  623. "GoFlyAKi 3435.664N 08659.267W 0000000m Go Fly A Kite by Marco.. ",
  624. "FlntCrkA 3432.028N 08656.806W 0000000m Flint Creek Adventure by Marco",
  625. "HonordMn 3534.680N 08612.557W 0000000m Honored Mount by Southpaw ",
  626. "SafariZo 3440.697N 08700.774W 0000000m Safari Zone by Zaybex ",
  627. "JckDnlsC 3517.077N 08622.260W 0000000m Jack Daniels Cache by Rmearse ",
  628. "FrgttnPr 3509.599N 08633.282W 0000000m Forgotten Park by mdawg & muff",
  629. "DntOvrlk 3513.326N 08616.031W 0000000m Dont Overlook Me Cache ",
  630. "ArYStmpd 3513.039N 08615.110W 0000000m Are You Stumped Yet? cache ",
  631. "CchtthBn 3512.532N 08614.691W 0000000m Cache at the Bend ",
  632. "Thtsnkng 3609.009N 08530.314W 0000000m That sinking feeling by Tntcac",
  633. "GamersCc 3449.136N 08635.836W 0000000m mer's Cache by avoral ",
  634. "CchMIfYC 3452.455N 08620.648W 0000000m Cache Me If You Can! by Glen H",
  635. "SavageVs 3526.915N 08535.136W 0000000m Savage Vista by White Dog Pack",
  636. "PrtrnG15 3555.479N 08653.274W 0000000m Praetorian Guards Hail Caesar #15!",
  637. "WtrlnAmp 3443.722N 08632.535W 0000000m Waterline Amphitheater by Fath",
  638. "BysLttlC 3447.569N 08638.448W 0000000m Boys' Little Cache by Zaybex ",
  639. "DrgnsBrt 3443.779N 08635.188W 0000000m Dragon's Breath by Zaybex ",
  640. "CryBbyHl 3430.733N 08657.362W 0000000m Cry Baby Hollow Cache by La Pa",
  641. "Parmer 3606.218N 08651.590W 0000000m Parmer by A182pilot & Family ",
  642. "JnnfrndJ 3438.141N 08632.991W 0000000m Jennifer and Jonathans Cliff C",
  643. "ALDRIDGE 3435.305N 08632.868W 0000000m ALDRIDGE CREEK LOTTA LOOT!! by",
  644. "RcktCtyS 3440.032N 08631.352W 0000000m Rocket City Stash by David Upt",
  645. "TrgcAccd 3608.561N 08648.381W 0000000m Tragic Accident by Campaholics",
  646. "FALLENTR 3439.210N 08631.104W 0000000m FALLEN TREE 4 MILE POST by zac",
  647. "TrshOt15 3558.964N 08646.064W 0000000m Cache In Trash Out # 15 by Jo",
  648. "TrshOt13 3602.214N 08650.428W 0000000m Cache In Trash Out #13 by JoGP",
  649. "PrcysDrp 3604.312N 08653.465W 0000000m Percys Dripping Springs by KLi",
  650. "TrshOt14 3605.292N 08648.560W 0000000m Cache In Trash Out # 14 by JoG",
  651. "PrtrnGr5 3557.621N 08640.278W 0000000m Praetorian Guards Hail Caesar #5!",
  652. "PrtrnGr4 3557.370N 08640.201W 0000000m Praetorian Guards Hail Caesar #4!",
  653. "PrtrnGr3 3557.250N 08640.047W 0000000m Praetorian Guards Hail Caesar #3!",
  654. "GrnMntnC 3439.120N 08631.100W 0000000m Green Mountain Cache by Steve ",
  655. "TrshOt12 3605.330N 08635.817W 0000000m Cache In Trash Out #12 by JoGP",
  656. "BlncngAc 3608.579N 08648.120W 0000000m Balancing Act by Campaholics ",
  657. "DittoCac 3434.652N 08633.310W 0000000m Ditto Cache by mookey ",
  658. "EraserCc 3431.888N 08633.024W 0000000m Eraser Cache by Zaybex ",
  659. "FrMlPstE 3439.440N 08630.180W 0000000m Four Mile Post Extension Cache",
  660. "MllrdFxC 3439.578N 08706.552W 0000000m Mallard-Fox Creek Cache by bam",
  661. "FireCach 3443.908N 08630.318W 0000000m he by Glen Pam Chase M ",
  662. "FlntRvrC 3443.170N 08625.990W 0000000m Flint River Canoe Cache by Ran",
  663. "ArabinCc 3419.104N 08628.765W 0000000m The Arabian Cache by WesNSpace",
  664. "CvrdBrdg 3412.406N 08659.392W 0000000m Covered Bridge Cache by pmarkh",
  665. "MilesTCc 3424.470N 08611.720W 0000000m Miles Too Cache by Rmearse ",
  666. "MbryOvrl 3423.803N 08611.922W 0000000m Mabrey Overlook Me by DDVaughn",
  667. "LwEnfrcm 3423.218N 08612.258W 0000000m Law Enforcement Cache by DDVau",
  668. "GrndDddy 3423.128N 08612.025W 0000000m Grand Daddys Home by Rmearse ",
  669. "BamaCach 3421.459N 08611.686W 0000000m The Bama Cache by DDVaughn & T",
  670. "Canyons 3440.085N 08600.910W 0000000m The Canyons by Aubrey and Josh",
  671. "ADamGodV 3511.677N 08616.587W 0000000m A Dam Good View by mdawg & muf",
  672. "UNDERTHE 3446.918N 08739.790W 0000000m UNDER THE ROCK by RUNNINGWILD ",
  673. "SQUIRREL 3448.712N 08741.681W 0000000m SQUIRREL'S NEST by RUNNINGWILD",
  674. "WlknthPr 3448.273N 08741.844W 0000000m Walk in the Park by Runningwil",
  675. "NetsClue 3448.494N 08741.977W 0000000m Net's Clues by Runningwild Adv",
  676. "NatrlBrd 3405.583N 08736.909W 0000000m Natural Bridge by Southeast Xt",
  677. "TrnglPrk 3341.448N 08640.980W 0000000m Triangle Park Cache by Charles",
  678. "LttlRvrI 3421.855N 08539.597W 0000000m Little River Initiative by spa",
  679. "GimmShlt 3430.087N 08536.834W 0000000m Gimme Shelter by Big Rock & Po",
  680. "GnomeTrs 3433.081N 08535.849W 0000000m Gnome Treasure by Big Rock ",
  681. "FlyingTr 3608.594N 08648.179W 0000000m Flying Torso by Campaholics ",
  682. "CultivtC 3608.582N 08648.064W 0000000m Cultivate a Cure by Campahol"
  683. }
  684. ;
  685. main()
  686. {
  687. char** foop = foo;
  688. int r;
  689. printf("%s\n", mkshort("The Troll"));
  690. printf("%s\n", mkshort("EFI"));
  691. printf("%s\n", mkshort("the Troll"));
  692. printf("%s\n", mkshort("the Trolley"));
  693. printf("%s\n", mkshort("The Troll Lives Under The Bridge"));
  694. printf("%s\n", mkshort("The \"Troll\" Lives Under $$ The Bridge!"));
  695. printf("%s\n", mkshort("The Trolley Goes Round"));
  696. printf("%s\n", mkshort("Cache In / Trash Out #1"));
  697. printf("%s\n", mkshort("Cache In / Trash Out #2"));
  698. printf("%s\n", mkshort("Cache In / Trash Out #137"));
  699. while (0 && *foop) {
  700. printf("%s %s\n", mkshort(*foop+39), *foop+39);
  701. foop++;
  702. }
  703. printf("%s\n", delete_last_vowel(0, "the quick brown foo", &r));
  704. printf("%s\n", delete_last_vowel(0, "the quick brown fox", &r));
  705. printf("%s\n", delete_last_vowel(0, "xxx", &r));
  706. printf("%s\n", delete_last_vowel(0, "ixxx", &r));
  707. printf("%s\n", delete_last_vowel(0, "aexxx", &r));
  708. }
  709. #endif