bridge/class-master/depend/pari/src/language/es.c
/* Outputs a beautiful error message (not \n terminated)
 *   msg is errmessage to print.
 *   s points to the offending chars.
 *   entry tells how much we can go back from s[0] */
Outputs a beautiful error message (not \n terminated)
msg is errmessage to print.
s points to the offending chars.
entry tells how much we can go back from s[0]
Outputs a beautiful error message ( not \ n terminated ) msg is errmessage to print . s points to the offending chars . entry tells how much we can go back from s [ 0 ]
void
print_errcontext(PariOUT *out,
                 const char *msg, const char *s, const char *entry)
{
  const long MAX_PAST = 25;
  long past = s - entry, future, lmsg;
  char str[CONTEXT_LEN + 1 + 1], pre[MAX_TERM_COLOR + 8 + 1];
  char *buf, *t;
  if (!s || !entry) { print_prefixed_text(out, msg,"  ***   ",NULL); return; }
  lmsg = strlen(msg);
  t = buf = (char*)pari_malloc(lmsg + MAX_PAST + 2 + 3 + MAX_TERM_COLOR + 1);
  memcpy(t, msg, lmsg); t += lmsg;
  strcpy(t, ": "); t += 2;
  if (past <= 0) past = 0;
  else
  {
    if (past > MAX_PAST) { past = MAX_PAST; strcpy(t, "..."); t += 3; }
    term_get_color(t, c_OUTPUT);
    t += strlen(t);
    memcpy(t, s - past, past); t[past] = 0;
  }
  t = str; if (!past) *t++ = ' ';
  future = CONTEXT_LEN - past;
  strncpy(t, s, future); t[future] = 0;
  term_get_color(pre, c_ERR);
  strcat(pre, "  ***   ");
  print_prefixed_text(out, buf, pre, str);
  pari_free(buf);
}
void print_errcontext ( PariOUT * out , const char * msg , const char * s , const char * entry ) { const long MAX_PAST = 25 ; long past = s - entry , future , lmsg ; char str [ CONTEXT_LEN + 1 + 1 ] , pre [ MAX_TERM_COLOR + 8 + 1 ] ; char * buf , * t ; if ( ! s || ! entry ) { print_prefixed_text ( out , msg , " " , NULL ) ; return ; } lmsg = strlen ( msg ) ; t = buf = ( char * ) pari_malloc ( lmsg + MAX_PAST + 2 + 3 + MAX_TERM_COLOR + 1 ) ; memcpy ( t , msg , lmsg ) ; t += lmsg ; strcpy ( t , " " ) ; t += 2 ; if ( past <= 0 ) past = 0 ; else { if ( past > MAX_PAST ) { past = MAX_PAST ; strcpy ( t , " " ) ; t += 3 ; } term_get_color ( t , c_OUTPUT ) ; t += strlen ( t ) ; memcpy ( t , s - past , past ) ; t [ past ] = 0 ; } t = str ; if ( ! past ) * t ++ = ' ' ; future = CONTEXT_LEN - past ; strncpy ( t , s , future ) ; t [ future ] = 0 ; term_get_color ( pre , c_ERR ) ; strcat ( pre , " " ) ; print_prefixed_text ( out , buf , pre , str ) ; pari_free ( buf ) ; }
Outputs a beautiful error message (not \n terminated)
   msg is errmessage to print.
Outputs a beautiful error message ( not \ n terminated ) msg is errmessage to print .
/* message + context */ /* msg + past + ': ' + '...' + term_get_color + \0 */ /* suffix (past arrow) */ /* prefix '***' */ /* now print */