File: charset.c

package info (click to toggle)
mixal 1.08-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 208 kB
  • ctags: 286
  • sloc: ansic: 1,597; makefile: 89; awk: 10
file content (23 lines) | stat: -rw-r--r-- 531 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* MIX simulator, copyright 1994 by Darius Bacon */ 
#include "mix.h"
#include "charset.h"

#include <assert.h>
#include <ctype.h>
#include <string.h>

static const char mix_chars[65] = 
    " abcdefghi^jklmnopqr^^stuvwxyz0123456789.,()+-*/=$<>@;:'???????";

char mix_to_C_char(Byte mix_char)
{
    assert((unsigned)mix_char < sizeof mix_chars);
    return mix_chars[(unsigned)mix_char];
}

Byte C_char_to_mix(char c)
{
    const char *s = strchr(mix_chars, tolower(c));
    if (!s) return 63;
    return (Byte) (s - mix_chars);
}