Beispiel #1
0
void TsToStringDate(Ts *ts, int show_nonspecific, int maxlen,
                    /* RESULTS */ char *out)
{
  struct tm *tms;
  *out = TERM;
  if (ts->flag & TSFLAG_TOD) {
    TodToString((Tod)ts->unixts, maxlen, out);
  } else if (ts->flag & TSFLAG_DUR) {
    DurToString((Tod)ts->unixts, maxlen, out);
  } else if (ts->unixts == UNIXTSNA) {
    if (show_nonspecific) StringCpy(out, "na", maxlen);
  } else if (ts->unixts == UNIXTSNEGINF) {
    if (show_nonspecific) StringCpy(out, "-Inf", maxlen);
  } else if (ts->unixts == UNIXTSPOSINF) {
    if (show_nonspecific) StringCpy(out, "Inf", maxlen);
  } else {
    if (NULL == (tms = localtime(&ts->unixts))) {
      StringCpy(out, "error", maxlen);
    } else {
      sprintf(out, "%.4d%.2d%.2d", 1900+tms->tm_year, tms->tm_mon+1,
              tms->tm_mday);
    }
  }
  if (ts->cx != ContextRoot) {
    ContextNameToString(ts->cx, StringEndOf(out));
  }
}
Beispiel #2
0
void StringAppendIfNotAlreadyIn(int in, int maxlen, /* RESULTS */ char *out)
{
  char	*p;
  maxlen--;
  p = StringEndOf(out);
  if (!StringIn(in, out)) {
    if ((p - out) >= maxlen) { out[maxlen] = TERM; return; }
    p[0] = in;
    p[1] = TERM;
  }
}
Beispiel #3
0
void StringAppendLen(/* RESULTS */ char *s1, /* INPUT */ char *s2, int len)
{
  s1 = StringEndOf(s1);
  while (len > 0) {
    *s1 = *s2;
    s1++;
    s2++;
    len--;
  }
  *s1 = TERM;
}
Beispiel #4
0
void StringAppendIfNotAlreadyIns(char *in, int maxlen, /* RESULTS */ char *out)
{
  char	*p;
  maxlen--;
  p = StringEndOf(out);
  while (*in) {
    if (!StringIn(*in, out)) {
      if ((p - out) >= maxlen) {
        out[maxlen] = TERM;
        return;
      }
      *p = *in;
      p++;
      *p = TERM;
    }
    in++;
  }
  *p = TERM;
}
Beispiel #5
0
/* Used in printing word syntax.
 * Long form; contrast with TextPrintWordAndFeatures.
 * (Both long and short forms are used by Dict.)
 */
void ThetaRoleTextPrint1(Text *text, int html, int lang, int position,
                         Obj *cas_restrict, ThetaRole *theta_roles, Obj *con,
                         Discourse *dc)
{
    int		subcat, slotnum, dospace;
    Obj		*cas, *restrict;
    Bool		isoptional;
    char		*p, buf[PHRASELEN], *s;
    LexEntry	*le;
    for (slotnum = 1; theta_roles; theta_roles = theta_roles->next, slotnum++) {
        if (theta_roles->cas == N("expl")) {
            slotnum--;
        }
        if (position != theta_roles->position) continue;
        if (cas_restrict && cas_restrict != theta_roles->cas) continue;
        ThetaRoleGet(theta_roles, &le, &cas, &subcat, &isoptional);
        if (cas == ObjNA) {
            buf[0] = LBRACE;
            buf[1] = TERM;
            p = buf+1;
        } else if (cas == N("expl")) {
            buf[0] = TERM;
            p = buf;
        } else if (isoptional) {
            buf[0] = LPAREN;
            buf[1] = TERM;
            p = buf+1;
        } else {
            buf[0] = LBRACKET;
            buf[1] = TERM;
            p = buf+1;
        }
        if (html) {
            TextPuts(buf, text);
        }
        if (cas != ObjNA && cas != N("expl")) {
            if (html) {
                HTML_TextPrint(text, GenConceptAbbrevString(cas, 1, dc));
            } else {
                StringCpy(p, GenConceptAbbrevString(cas, 1, dc), PHRASELEN-1);
            }
            dospace = 1;
        } else {
            dospace = 0;
        }
        if (con && (cas != N("expl"))) restrict = DbGetRestriction(con, slotnum);
        else restrict = NULL;
        if (restrict == N("concept") || restrict == N("object")) restrict = NULL;
        if (le) {
            if (dospace) {
                if (html) {
                    TextPutc(SPACE, text);
                } else {
                    StringAppendChar(buf, PHRASELEN, SPACE);
                }
                dospace = 0;
            }
            if (html) {
                LexEntryAddSep(le, le->srcphrase, PHRASELEN, buf);
                HTML_TextPrintBoldBeginIfEnglish(text, lang);
                HTML_TextPrint(text, buf);
                TextPutc(SPACE, text);
                HTML_TextPrintBoldEndIfEnglish(text, lang);
            } else {
                LexEntryAddSep(le, le->srcphrase, PHRASELEN, StringEndOf(buf));
            }
            if (cas != N("expl")) {
                if (html) {
                    TextPutc('+', text);
                } else {
                    StringAppendChar(buf, PHRASELEN, '+');
                }
            }
        }
        if (restrict && !ObjIsList(restrict)) {
            if (dospace) {
                if (html) {
                    TextPutc(SPACE, text);
                } else {
                    StringAppendChar(buf, PHRASELEN, SPACE);
                }
                dospace = 0;
            }
            if (html) {
                HTML_TextLinkToObj(text, restrict, 1, 0, 0);
            } else {
                GenConceptString(restrict, N("empty-article"), F_NOUN, F_NULL,
                                 DC(dc).lang, F_NULL, F_NULL, F_NULL, PHRASELEN,
                                 1, 0, dc, p = StringEndOf(buf));
                StringToUpperDestructive(p);
            }
            dospace = 1;
        }
        if (subcat != F_NULL) {
            if (html) {
                if ((s = GenFeatAbbrevString(subcat, 1, dc))) {
                    TextPuts(s, text);
                }
            } else {
                if ((s = GenFeatAbbrevString(subcat, 1, dc))) {
                    StringCat(buf, s, PHRASELEN);
                }
            }
        }
        if (html) {
            if (cas == ObjNA) TextPutc(RBRACE, text);
            else if (cas == N("expl")) Nop();
            else if (isoptional) TextPutc(RPAREN, text);
            else TextPutc(RBRACKET, text);
            TextPutc(SPACE, text);
        } else {
            if (cas == ObjNA) StringAppendChar(buf, PHRASELEN, RBRACE);
            else if (cas == N("expl")) Nop();
            else if (isoptional) StringAppendChar(buf, PHRASELEN, RPAREN);
            else StringAppendChar(buf, PHRASELEN, RBRACKET);
            TextPutword(buf, TERM, text);
        }
    }
}