tohtml.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include <String.h>
  5. #include <thread.h>
  6. #include "wiki.h"
  7. /*
  8. * Get HTML and text templates from underlying file system.
  9. * Caches them, so that changes don't take effect for
  10. * up to Tcache seconds after they are made.
  11. *
  12. * If the files are deleted, we keep returning the last
  13. * known copy.
  14. */
  15. enum {
  16. WAIT = 60
  17. };
  18. static char *name[2*Ntemplate] = {
  19. [Tpage] "page.html",
  20. [Tedit] "edit.html",
  21. [Tdiff] "diff.html",
  22. [Thistory] "history.html",
  23. [Tnew] "new.html",
  24. [Toldpage] "oldpage.html",
  25. [Twerror] "werror.html",
  26. [Ntemplate+Tpage] "page.txt",
  27. [Ntemplate+Tdiff] "diff.txt",
  28. [Ntemplate+Thistory] "history.txt",
  29. [Ntemplate+Toldpage] "oldpage.txt",
  30. [Ntemplate+Twerror] "werror.txt",
  31. };
  32. static struct {
  33. RWLock;
  34. String *s;
  35. ulong t;
  36. Qid qid;
  37. } cache[2*Ntemplate];
  38. static void
  39. cacheinit(void)
  40. {
  41. int i;
  42. static int x;
  43. static Lock l;
  44. if(x)
  45. return;
  46. lock(&l);
  47. if(x){
  48. unlock(&l);
  49. return;
  50. }
  51. for(i=0; i<2*Ntemplate; i++)
  52. if(name[i])
  53. cache[i].s = s_copy("");
  54. x = 1;
  55. unlock(&l);
  56. }
  57. static String*
  58. gettemplate(int type)
  59. {
  60. int n;
  61. Biobuf *b;
  62. Dir *d;
  63. String *s, *ns;
  64. if(name[type]==nil)
  65. return nil;
  66. cacheinit();
  67. rlock(&cache[type]);
  68. if(0 && cache[type].t+Tcache >= time(0)){
  69. s = s_incref(cache[type].s);
  70. runlock(&cache[type]);
  71. return s;
  72. }
  73. runlock(&cache[type]);
  74. // d = nil;
  75. wlock(&cache[type]);
  76. if(0 && cache[type].t+Tcache >= time(0) || (d = wdirstat(name[type])) == nil)
  77. goto Return;
  78. if(0 && d->qid.vers == cache[type].qid.vers && d->qid.path == cache[type].qid.path){
  79. cache[type].t = time(0);
  80. goto Return;
  81. }
  82. if((b = wBopen(name[type], OREAD)) == nil)
  83. goto Return;
  84. ns = s_reset(nil);
  85. n = s_read(b, ns, 10000);
  86. Bterm(b);
  87. if(n <= 0)
  88. goto Return;
  89. s_free(cache[type].s);
  90. cache[type].s = ns;
  91. cache[type].qid = d->qid;
  92. cache[type].t = time(0);
  93. Return:
  94. free(d);
  95. s = s_incref(cache[type].s);
  96. wunlock(&cache[type]);
  97. return s;
  98. }
  99. /*
  100. * Write wiki document in HTML.
  101. */
  102. static String*
  103. s_escappend(String *s, char *p, int pre)
  104. {
  105. char *q;
  106. while(q = strpbrk(p, pre ? "<>&" : " <>&")){
  107. s = s_nappend(s, p, q-p);
  108. switch(*q){
  109. case '<':
  110. s = s_append(s, "&lt;");
  111. break;
  112. case '>':
  113. s = s_append(s, "&gt;");
  114. break;
  115. case '&':
  116. s = s_append(s, "&amp;");
  117. break;
  118. case ' ':
  119. s = s_append(s, "\n");
  120. }
  121. p = q+1;
  122. }
  123. s = s_append(s, p);
  124. return s;
  125. }
  126. static char*
  127. mkurl(char *s, int ty)
  128. {
  129. char *p, *q;
  130. if(strncmp(s, "http:", 5)==0
  131. || strncmp(s, "ftp:", 4)==0
  132. || strncmp(s, "mailto:", 7)==0
  133. || strncmp(s, "telnet:", 7)==0
  134. || strncmp(s, "file:", 5)==0)
  135. return estrdup(s);
  136. if(strchr(s, ' ')==nil && strchr(s, '@')!=nil){
  137. p = emalloc(strlen(s)+8);
  138. strcpy(p, "mailto:");
  139. strcat(p, s);
  140. return p;
  141. }
  142. if(ty == Toldpage)
  143. p = smprint("../../%s", s);
  144. else
  145. p = smprint("../%s", s);
  146. for(q=p; *q; q++)
  147. if(*q==' ')
  148. *q = '_';
  149. return p;
  150. }
  151. String*
  152. pagehtml(String *s, Wpage *wtxt, int ty)
  153. {
  154. int inlist, inpre, inpara;
  155. char *p, tmp[40];
  156. Wpage *w;
  157. inlist = 0;
  158. inpre = 0;
  159. inpara = 0;
  160. for(w=wtxt; w; w=w->next){
  161. switch(w->type){
  162. case Wheading:
  163. if(!inpara){
  164. inpara = 1;
  165. s = s_append(s, "\n<p>\n");
  166. }
  167. s = s_appendlist(s, "<b>", w->text, "</b>\n<p>\n", nil);
  168. break;
  169. case Wpara:
  170. if(inlist){
  171. inlist = 0;
  172. s = s_append(s, "\n</ul>\n");
  173. }
  174. if(inpre){
  175. inpre = 0;
  176. s = s_append(s, "</pre>\n");
  177. }
  178. if(!inpara){
  179. inpara = 1;
  180. s = s_append(s, "\n<p>\n");
  181. }
  182. break;
  183. case Wbullet:
  184. if(inpre){
  185. inpre = 0;
  186. s = s_append(s, "</pre>\n");
  187. }
  188. if(!inlist){
  189. inlist = 1;
  190. s = s_append(s, "\n<ul>\n");
  191. }
  192. if(inpara)
  193. inpara = 0;
  194. s = s_append(s, "\n<li>\n");
  195. break;
  196. case Wlink:
  197. if(inpara)
  198. inpara = 0;
  199. if(w->url == nil)
  200. p = mkurl(w->text, ty);
  201. else
  202. p = w->url;
  203. s = s_appendlist(s, "<a href=\"", p, "\">", nil);
  204. s = s_escappend(s, w->text, 0);
  205. s = s_append(s, "</a>");
  206. if(w->url == nil)
  207. free(p);
  208. break;
  209. case Wman:
  210. if(inpara)
  211. inpara = 0;
  212. sprint(tmp, "%d", w->section);
  213. s = s_appendlist(s,
  214. "<a href=\"http://plan9.bell-labs.com/magic/man2html/",
  215. tmp, "/", w->text, "\"><i>", w->text, "</i>(",
  216. tmp, ")</a>", nil);
  217. break;
  218. case Wpre:
  219. if(inpara)
  220. inpara = 0;
  221. if(inlist){
  222. inlist = 0;
  223. s = s_append(s, "\n</ul>\n");
  224. }
  225. if(!inpre){
  226. inpre = 1;
  227. s = s_append(s, "\n<pre>\n");
  228. }
  229. s = s_escappend(s, w->text, 1);
  230. s = s_append(s, "\n");
  231. break;
  232. case Wplain:
  233. if(inpara)
  234. inpara = 0;
  235. s = s_escappend(s, w->text, 0);
  236. break;
  237. }
  238. }
  239. if(inlist)
  240. s = s_append(s, "\n</ul>\n");
  241. if(inpre)
  242. s = s_append(s, "</pre>\n");
  243. if(!inpara)
  244. s = s_append(s, "\n<p>\n");
  245. return s;
  246. }
  247. static String*
  248. grey(String *s)
  249. {
  250. return s_append(s, "<font color=#777777>");
  251. }
  252. static String*
  253. ungrey(String *s)
  254. {
  255. return s_append(s, "</font>");
  256. }
  257. static String*
  258. copythru(String *s, char **newp, int *nlinep, int l)
  259. {
  260. char *oq, *q, *r;
  261. int ol;
  262. q = *newp;
  263. oq = q;
  264. ol = *nlinep;
  265. while(ol < l){
  266. if(r = strchr(q, '\n'))
  267. q = r+1;
  268. else{
  269. q += strlen(q);
  270. break;
  271. }
  272. ol++;
  273. }
  274. if(*nlinep < l)
  275. *nlinep = l;
  276. *newp = q;
  277. return s_nappend(s, oq, q-oq);
  278. }
  279. static int
  280. dodiff(char *f1, char *f2)
  281. {
  282. int p[2];
  283. if(pipe(p) < 0){
  284. return -1;
  285. }
  286. switch(fork()){
  287. case -1:
  288. return -1;
  289. case 0:
  290. close(p[0]);
  291. dup(p[1], 1);
  292. execl("/bin/diff", "diff", f1, f2, nil);
  293. _exits(nil);
  294. }
  295. close(p[1]);
  296. return p[0];
  297. }
  298. /* print document i grayed out, with only diffs relative to j in black */
  299. static String*
  300. s_diff(String *s, Whist *h, int i, int j)
  301. {
  302. char *p, *q, *pnew;
  303. int fdiff, fd1, fd2, n1, n2;
  304. Biobuf b;
  305. char fn1[40], fn2[40];
  306. String *new, *old;
  307. int nline;
  308. if(j < 0)
  309. return pagehtml(s, h->doc[i].wtxt, Tpage);
  310. strcpy(fn1, "/tmp/wiki.XXXXXX");
  311. strcpy(fn2, "/tmp/wiki.XXXXXX");
  312. if((fd1 = opentemp(fn1)) < 0 || (fd2 = opentemp(fn2)) < 0){
  313. close(fd1);
  314. s = s_append(s, "\nopentemp failed; sorry\n");
  315. return s;
  316. }
  317. new = pagehtml(s_reset(nil), h->doc[i].wtxt, Tpage);
  318. old = pagehtml(s_reset(nil), h->doc[j].wtxt, Tpage);
  319. write(fd1, s_to_c(new), s_len(new));
  320. write(fd2, s_to_c(old), s_len(old));
  321. fdiff = dodiff(fn2, fn1);
  322. if(fdiff < 0)
  323. s = s_append(s, "\ndiff failed; sorry\n");
  324. else{
  325. nline = 0;
  326. pnew = s_to_c(new);
  327. Binit(&b, fdiff, OREAD);
  328. while(p = Brdline(&b, '\n')){
  329. if(p[0]=='<' || p[0]=='>' || p[0]=='-')
  330. continue;
  331. p[Blinelen(&b)-1] = '\0';
  332. if((q = strpbrk(p, "acd")) == nil)
  333. continue;
  334. switch(*q){
  335. case 'a':
  336. case 'c':
  337. n1 = atoi(q+1);
  338. if(q = strchr(q, ','))
  339. n2 = atoi(q+1);
  340. else
  341. n2 = n1;
  342. s = grey(s);
  343. s = copythru(s, &pnew, &nline, n1-1);
  344. s = ungrey(s);
  345. s = copythru(s, &pnew, &nline, n2);
  346. break;
  347. }
  348. }
  349. close(fdiff);
  350. s = grey(s);
  351. s = s_append(s, pnew);
  352. s = ungrey(s);
  353. }
  354. s_free(new);
  355. s_free(old);
  356. close(fd1);
  357. close(fd2);
  358. return s;
  359. }
  360. static String*
  361. diffhtml(String *s, Whist *h)
  362. {
  363. int i;
  364. char tmp[50];
  365. char *atime;
  366. for(i=h->ndoc-1; i>=0; i--){
  367. s = s_append(s, "<hr>\n");
  368. if(i==h->current)
  369. sprint(tmp, "index.html");
  370. else
  371. sprint(tmp, "%lud", h->doc[i].time);
  372. atime = ctime(h->doc[i].time);
  373. atime[strlen(atime)-1] = '\0';
  374. s = s_appendlist(s,
  375. "<a href=\"", tmp, "\">",
  376. atime, "</a>", nil);
  377. if(h->doc[i].author)
  378. s = s_appendlist(s, ", ", h->doc[i].author, nil);
  379. if(h->doc[i].conflict)
  380. s = s_append(s, ", conflicting write");
  381. s = s_append(s, "\n");
  382. if(h->doc[i].comment)
  383. s = s_appendlist(s, "<br><i>", h->doc[i].comment, "</i>\n", nil);
  384. s = s_append(s, "<br><hr>");
  385. s = s_diff(s, h, i, i-1);
  386. }
  387. s = s_append(s, "<hr>");
  388. return s;
  389. }
  390. static String*
  391. historyhtml(String *s, Whist *h)
  392. {
  393. int i;
  394. char tmp[40];
  395. char *atime;
  396. s = s_append(s, "<ul>\n");
  397. for(i=h->ndoc-1; i>=0; i--){
  398. if(i==h->current)
  399. sprint(tmp, "index.html");
  400. else
  401. sprint(tmp, "%lud", h->doc[i].time);
  402. atime = ctime(h->doc[i].time);
  403. atime[strlen(atime)-1] = '\0';
  404. s = s_appendlist(s,
  405. "<li><a href=\"", tmp, "\">",
  406. atime, "</a>", nil);
  407. if(h->doc[i].author)
  408. s = s_appendlist(s, ", ", h->doc[i].author, nil);
  409. if(h->doc[i].conflict)
  410. s = s_append(s, ", conflicting write");
  411. s = s_append(s, "\n");
  412. if(h->doc[i].comment)
  413. s = s_appendlist(s, "<br><i>", h->doc[i].comment, "</i>\n", nil);
  414. }
  415. s = s_append(s, "</ul>");
  416. return s;
  417. }
  418. String*
  419. tohtml(Whist *h, Wdoc *d, int ty)
  420. {
  421. char *atime;
  422. char *p, *q, ver[40];
  423. int nsub;
  424. Sub sub[3];
  425. String *s, *t;
  426. t = gettemplate(ty);
  427. if(p = strstr(s_to_c(t), "PAGE"))
  428. q = p+4;
  429. else{
  430. p = s_to_c(t)+s_len(t);
  431. q = nil;
  432. }
  433. nsub = 0;
  434. if(h){
  435. sub[nsub] = (Sub){ "TITLE", h->title };
  436. nsub++;
  437. }
  438. if(d){
  439. sprint(ver, "%lud", d->time);
  440. sub[nsub] = (Sub){ "VERSION", ver };
  441. nsub++;
  442. atime = ctime(d->time);
  443. atime[strlen(atime)-1] = '\0';
  444. sub[nsub] = (Sub){ "DATE", atime };
  445. nsub++;
  446. }
  447. s = s_reset(nil);
  448. s = s_appendsub(s, s_to_c(t), p-s_to_c(t), sub, nsub);
  449. switch(ty){
  450. case Tpage:
  451. case Toldpage:
  452. s = pagehtml(s, d->wtxt, ty);
  453. break;
  454. case Tedit:
  455. s = pagetext(s, d->wtxt, 0);
  456. break;
  457. case Tdiff:
  458. s = diffhtml(s, h);
  459. break;
  460. case Thistory:
  461. s = historyhtml(s, h);
  462. break;
  463. case Tnew:
  464. case Twerror:
  465. break;
  466. }
  467. if(q)
  468. s = s_appendsub(s, q, strlen(q), sub, nsub);
  469. s_free(t);
  470. return s;
  471. }
  472. enum {
  473. LINELEN = 70,
  474. };
  475. static String*
  476. s_appendbrk(String *s, char *p, char *prefix, int dosharp)
  477. {
  478. char *e, *w, *x;
  479. int first, l;
  480. first = 1;
  481. while(*p){
  482. s = s_append(s, p);
  483. e = strrchr(s_to_c(s), '\n');
  484. if(e == nil)
  485. e = s_to_c(s);
  486. else
  487. e++;
  488. l = utflen(e);
  489. if(l <= LINELEN)
  490. break;
  491. /* BUG: should be LINELEN utf chars not LINELEN bytes */
  492. x = strchr(e+LINELEN, ' ');
  493. if(x){
  494. *x = '\0';
  495. w = strrchr(e, ' ');
  496. *x = ' ';
  497. }else
  498. w = strrchr(e, ' ');
  499. if(w-s_to_c(s) < strlen(prefix))
  500. break;
  501. x = estrdup(w+1);
  502. *w = '\0';
  503. s->ptr = w;
  504. s_append(s, "\n");
  505. if(dosharp)
  506. s_append(s, "#");
  507. s_append(s, prefix);
  508. if(!first)
  509. free(p);
  510. first = 0;
  511. p = x;
  512. }
  513. if(!first)
  514. free(p);
  515. return s;
  516. }
  517. static void
  518. s_endline(String *s, int dosharp)
  519. {
  520. if(dosharp){
  521. if(s->ptr == s->base+1 && s->ptr[-1] == '#')
  522. return;
  523. if(s->ptr > s->base+1 && s->ptr[-1] == '#' && s->ptr[-2] == '\n')
  524. return;
  525. s_append(s, "\n#");
  526. }else{
  527. if(s->ptr > s->base+1 && s->ptr[-1] == '\n')
  528. return;
  529. s_append(s, "\n");
  530. }
  531. }
  532. String*
  533. pagetext(String *s, Wpage *page, int dosharp)
  534. {
  535. int inlist, inpara;
  536. char *prefix, *sharp, tmp[40];
  537. String *t;
  538. Wpage *w;
  539. inlist = 0;
  540. inpara = 0;
  541. prefix = "";
  542. sharp = dosharp ? "#" : "";
  543. s = s_append(s, sharp);
  544. for(w=page; w; w=w->next){
  545. switch(w->type){
  546. case Wheading:
  547. if(inlist){
  548. prefix = "";
  549. inlist = 0;
  550. }
  551. s_endline(s, dosharp);
  552. if(!inpara){
  553. inpara = 1;
  554. s = s_appendlist(s, "\n", sharp, nil);
  555. }
  556. s = s_appendlist(s, w->text, "\n", sharp, "\n", sharp, nil);
  557. break;
  558. case Wpara:
  559. s_endline(s, dosharp);
  560. if(inlist){
  561. prefix = "";
  562. inlist = 0;
  563. }
  564. if(!inpara){
  565. inpara = 1;
  566. s = s_appendlist(s, "\n", sharp, nil);
  567. }
  568. break;
  569. case Wbullet:
  570. s_endline(s, dosharp);
  571. if(!inlist)
  572. inlist = 1;
  573. if(inpara)
  574. inpara = 0;
  575. s = s_append(s, " *\t");
  576. prefix = "\t";
  577. break;
  578. case Wlink:
  579. if(inpara)
  580. inpara = 0;
  581. t = s_append(s_copy("["), w->text);
  582. if(w->url == nil)
  583. t = s_append(t, "]");
  584. else{
  585. t = s_append(t, " | ");
  586. t = s_append(t, w->url);
  587. t = s_append(t, "]");
  588. }
  589. s = s_appendbrk(s, s_to_c(t), prefix, dosharp);
  590. s_free(t);
  591. break;
  592. case Wman:
  593. if(inpara)
  594. inpara = 0;
  595. s = s_appendbrk(s, w->text, prefix, dosharp);
  596. sprint(tmp, "(%d)", w->section);
  597. s = s_appendbrk(s, tmp, prefix, dosharp);
  598. break;
  599. case Wpre:
  600. if(inlist){
  601. prefix = "";
  602. inlist = 0;
  603. }
  604. if(inpara)
  605. inpara = 0;
  606. s_endline(s, dosharp);
  607. s = s_appendlist(s, "! ", w->text, "\n", sharp, nil);
  608. break;
  609. case Wplain:
  610. if(inpara)
  611. inpara = 0;
  612. s = s_appendbrk(s, w->text, prefix, dosharp);
  613. break;
  614. }
  615. }
  616. s_endline(s, dosharp);
  617. s->ptr--;
  618. *s->ptr = '\0';
  619. return s;
  620. }
  621. static String*
  622. historytext(String *s, Whist *h)
  623. {
  624. int i;
  625. char tmp[40];
  626. char *atime;
  627. for(i=h->ndoc-1; i>=0; i--){
  628. if(i==h->current)
  629. sprint(tmp, "[current]");
  630. else
  631. sprint(tmp, "[%lud/]", h->doc[i].time);
  632. atime = ctime(h->doc[i].time);
  633. atime[strlen(atime)-1] = '\0';
  634. s = s_appendlist(s, " * ", tmp, " ", atime, nil);
  635. if(h->doc[i].author)
  636. s = s_appendlist(s, ", ", h->doc[i].author, nil);
  637. if(h->doc[i].conflict)
  638. s = s_append(s, ", conflicting write");
  639. s = s_append(s, "\n");
  640. if(h->doc[i].comment)
  641. s = s_appendlist(s, "<i>", h->doc[i].comment, "</i>\n", nil);
  642. }
  643. return s;
  644. }
  645. String*
  646. totext(Whist *h, Wdoc *d, int ty)
  647. {
  648. char *atime;
  649. char *p, *q, ver[40];
  650. int nsub;
  651. Sub sub[3];
  652. String *s, *t;
  653. t = gettemplate(Ntemplate+ty);
  654. if(p = strstr(s_to_c(t), "PAGE"))
  655. q = p+4;
  656. else{
  657. p = s_to_c(t)+s_len(t);
  658. q = nil;
  659. }
  660. nsub = 0;
  661. if(h){
  662. sub[nsub] = (Sub){ "TITLE", h->title };
  663. nsub++;
  664. }
  665. if(d){
  666. sprint(ver, "%lud", d->time);
  667. sub[nsub] = (Sub){ "VERSION", ver };
  668. nsub++;
  669. atime = ctime(d->time);
  670. atime[strlen(atime)-1] = '\0';
  671. sub[nsub] = (Sub){ "DATE", atime };
  672. nsub++;
  673. }
  674. s = s_reset(nil);
  675. s = s_appendsub(s, s_to_c(t), p-s_to_c(t), sub, nsub);
  676. switch(ty){
  677. case Tpage:
  678. case Toldpage:
  679. s = pagetext(s, d->wtxt, 0);
  680. break;
  681. case Thistory:
  682. s = historytext(s, h);
  683. break;
  684. case Tnew:
  685. case Twerror:
  686. break;
  687. }
  688. if(q)
  689. s = s_appendsub(s, q, strlen(q), sub, nsub);
  690. s_free(t);
  691. return s;
  692. }
  693. String*
  694. doctext(String *s, Wdoc *d)
  695. {
  696. char tmp[40];
  697. sprint(tmp, "D%lud", d->time);
  698. s = s_append(s, tmp);
  699. if(d->comment){
  700. s = s_append(s, "\nC");
  701. s = s_append(s, d->comment);
  702. }
  703. if(d->author){
  704. s = s_append(s, "\nA");
  705. s = s_append(s, d->author);
  706. }
  707. if(d->conflict)
  708. s = s_append(s, "\nX");
  709. s = s_append(s, "\n");
  710. s = pagetext(s, d->wtxt, 1);
  711. return s;
  712. }