view 3rdparty/packages/ed/esc.c @ 1427:b3868abe1fee

Rearrangement of directories and files for making bootable 6809/6309 MV disks
author boisy
date Tue, 02 Dec 2003 22:35:55 +0000
parents bef1844de0dc
children
line wrap: on
line source

/*      esc.c   */
#include <stdio.h>
#include "tools.h"

/* Map escape sequences into their equivalent symbols.  Returns the
 * correct ASCII character.  If no escape prefix is present then s
 * is untouched and *s is returned, otherwise **s is advanced to point
 * at the escaped character and the translated character is returned.
 */
int esc(s)
char **s;
{
  register int rval;

  if (**s != ESCAPE) {
        rval = **s;
  } else {
        (*s)++;

        switch (toupper(**s)) {
            case '\000':        rval = ESCAPE;  break;
            case 'S':   rval = ' ';     break;
            case 'N':   rval = '\n';    break;
            case 'T':   rval = '\t';    break;
            case 'B':   rval = '\b';    break;
            case 'R':   rval = '\r';    break;
            default:    rval = **s;     break;
        }
  }

  return(rval);
}