⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvistuff.c

📁 harvest是一个下载html网页得机器人
💻 C
📖 第 1 页 / 共 3 页
字号:
        case 30  :  if (!allchar) {                        outchar('O');                        ch = 'E';                    }                    break;  /* Dane/Norw OE    */        case 31  :  if (!allchar) {                        if (scascii)                            ch = '\\';                  /* Dane/Norw /O    */                        else                            ch = 'O';                    }                    break;        case 32  :  ch = allchar || ttfont ? ch : '_'; break;                                                        /* underlined blank */        case 58  :  ch = allchar || !mifont ? ch : '.'; break; /* if japan */        case 59  :  ch = allchar || !mifont ? ch : ','; break; /* if japan */        case 92  :  ch = allchar || ttfont ? ch : '"'; break;  /* \ from `` */        case 123 :  ch = allchar || ttfont ? ch : '-'; break;  /* { from -- */        case 124 :  ch = allchar || ttfont ? ch : '_'; break;  /* | from --- */        case 125 :  ch = allchar || ttfont ? ch : '"'; break;  /* } from \H */        case 126 :  ch = allchar || ttfont ? ch : '"'; break;  /* ~ from \~ */        case 127 :  if (!allchar) ch = '"'; break;             /* DEL from \" */        /*         * Or should I use SPACE for non-accents ???         * This seems to work ...         */        case 18  :  ch = !allchar && accent ? '`' : ch; break;  /* from \` */        case 19  :  ch = !allchar && accent ? 0x27 : ch; break; /* from \' */        case 20  :  ch = !allchar && accent ? '~' : ch; break;  /* from \v */        case 21  :  ch = !allchar && accent ? '~' : ch; break;  /* from \u */        case 22  :  ch = !allchar && accent ? '~' : ch; break;  /* from \= */        case 24  :  ch = !allchar && accent ? ',' : ch; break;  /* from \c */        case 94  :  ch = (!allchar && accent && !ttfont) ? '^' : ch; break;                                                                /* ^ from \^ */        case 95  :  ch = (!allchar && accent && !ttfont) ? '`' : ch; break;                                                                /* _ from \. */    }    outchar(ch);    return;} /* normchar *//* * OUTCHAR -- Here we put the character into the current page. *            This function includes some code to handle Scandinavian *            characters. I think that code doesn't belong here. IT *            SHOULD BE MOVED OUT. */void outchar(char ch){    register int i, j;/*     fprintf(stderr, "hor: %ld, ver: %ld\n", h, v); */#if defined(MSDOS) || defined(THINK_C)    if (labs(v - currentline->vv) > lineheight / 2L)#else    if (abs(v - currentline->vv) > lineheight / 2L)#endif        currentline = findline();#if 0    j = (int) (((double) h / (double) maxpagewidth) * (ttywidth-1)) + 1;#else    j = (int) (h / charwidth);#endif    if (j > rightmargin)     /* leftmargin <= j <= rightmargin */        j = rightmargin;    else if (j < leftmargin)        j = leftmargin;    foo = leftmargin - 1;    /*     * This code does not really belong here ...     *     *-------------------------------------------------------------*     * The following is very specialized code, it handles national *     * Swe/Fin characters. They are respectively: a and o with two *     * dots ("a & "o) and a with a circle (Oa). In Swe/Fin "ASCII" *     * these characters replace {}|[] and \.  TeX outputs these by *     * first issuing the dots or circle and then backspace and set *     * the a or o. When dvi2tty finds an a or o it searches in the *     * near vicinity for the character codes that represent circle *     * or dots and if one is found the corresponding national char *     * replaces the special character codes.                       *     *-------------------------------------------------------------*/    if (!allchar && scascii) {        if ((ch == 'a') || (ch == 'A') || (ch == 'o') || (ch == 'O')) {            for (i = IMAX(leftmargin, j-2);                 i <= IMIN(rightmargin, j+2);                 i++)                if ((currentline->text[i - leftmargin] == 127) || /* DEL */                    (currentline->text[i - leftmargin] == 34)  || /* "   */                    (currentline->text[i - leftmargin] == 23))                    foo = i;            if (foo >= leftmargin) {                j = (int) foo;                switch (currentline->text[j - leftmargin]) {                    case 127 :                    case 34  :                         /* DEL or " */                               if (ch == 'a')                                   ch = '{';            /* } vi */                               else if (ch == 'A')      /* dots ... */                                   ch = '[';                               else if (ch == 'o')                                   ch = '|';                               else if (ch == 'O')                                   ch = '\\';                               break;                    case 23  : if (ch == 'a')                                   ch = /* { vi */ '}';                               else if (ch == 'A')      /* circle */                                   ch = ']';                               break;                }            }        }    }    /*----------------- end of 'Scandinavian code' ----------------*/    if (foo == leftmargin-1)        while ((currentline->text[j - leftmargin] != SPACE)               && (j < rightmargin)) {            j++;            h += charwidth;        }    if ( allchar || ((ch >= SPACE) && (ch != DEL)) ||         (scascii && (ch == 23)) ) {          /*  (scascii && (ch == DEL)) )     if VMS ??? */        if (j < rightmargin)            currentline->text[j - leftmargin] = ch;        else            currentline->text[rightmargin - leftmargin] = '@';        if (j > currentline->charactercount)            currentline->charactercount = j;        if (j < firstcolumn)            firstcolumn = j;    }    h += charwidth;    return;} /* outchar *//* * PUTCHARACTER -- Output character, don't change h */void putcharacter(long charnr){    register long saveh;    saveh = h;    if (japan)        dochar((char) charnr);    else if (allchar || ((charnr >= 0) && (charnr <= LASTCHAR)))        outchar((char) charnr);    else        setchar(charnr);    h = saveh;    return;} /* putcharacter *//* * SETCHAR -- Should print characters with character code>127 from *            current font. Note that the parameter is a dummy, since *            ascii-chars are<=127. */void setchar(long charnr){    outchar(allchar ? charnr : '#');    return;} /* setchar *//* * FONTDEF -- Process a font definition. */void fontdef(int x){    register int i;    char * name;    font * fnt;    int namelen;    long fntnum;    int new = 0;    fntnum = num(x);    (void) get4();                      /* checksum */    (void) get4();                      /* scale */    (void) get4();                      /* design */    namelen = (int) get1() + (int) get1();    fnt = fonts;    while (fnt != NULL && fnt->num != fntnum)       /* does fontnum exist */        fnt = fnt->next;    if (fnt == NULL) {        if ((fnt = (font *) malloc(sizeof(font))) == NULL) {            perror("fontdef");            exit(1);        }        fnt->num = fntnum;        new = 1;    }    else        free(fnt->name);    /* free old name */    if ((name = (char *) malloc((namelen+1) * sizeof(char))) == NULL) {        perror("fontdef");        exit(1);    }    for (i = 0; i < namelen; i++)        name[i] = get1();    name[i] = '\0';	/* just to be sure */    fnt->name = name;    if (new) {        fnt->next = fonts;        fonts = fnt;    }    return;} /* fontdef *//* * SETFONT -- Switch to specific font. Try to find out if it is a symbol *            font. *            Option -c allchar does not pertain to this portion, so symbols *            are still translated. */void setfont(long fntnum){    font * fnt;    char * s;    char * d;    fnt = fonts;    while (fnt != NULL && fnt->num != fntnum)        fnt = fnt->next;    symbolfont = FALSE;    ttfont = FALSE;    mifont = FALSE;    jfontnum = 0;    if (fnt == NULL) {        /* error : font not found */        return;    }    s = fnt->name;    d = delim;      /* print delim and font name if -b was chosen */    if (printfont) {         while (*d !=0) {putcharacter(*d); d++;}         d = s;         while (*d !=0) {putcharacter(*d); d++;}         /* d = strrev(delim); */         while (*d !=0) {putcharacter(*d); d++;}    }    if (japan)        jfontnum = getjsubfont(s);    if (jfontnum == 0) {        while ((s = strchr(s, 's')) != NULL) {            if (strncmp("sy", s, 2) == 0) {                symbolfont = TRUE;                break;            }	    s++;      /* New line to fix bug; font names with 's' would hang */        }        s = fnt->name;        while ((s = strchr(s, 't')) != NULL) {            if (strncmp("tt", s, 2) == 0) {                ttfont = TRUE;                break;            }	    s++;      /* New line to fix bug; font names with 's' would hang */        }        s = fnt->name;        while ((s = strchr(s, 'm')) != NULL) {            if (strncmp("mi", s, 2) == 0) {                mifont = TRUE;                break;            }	    s++;      /* New line to fix bug; font names with 's' would hang */        }    }    return;} /* setfont */void jischar(long charnr){    int Ku, Ten;    compute_jis(jfontnum, (int) charnr, &Ku, &Ten);    outchar(Ku+128);    outchar(Ten+128);    return;} /* jischar */#define	kushift(c)	c+0x20#define	tenshift(c)	c+0x20void compute_jis(int f, int c, int *ku, int *ten){    int n;    if (f <= 7) {        if (f == 1) {            if (c >= 100) {                *ku = kushift(2);                *ten = tenshift(c-100);            }            else {                *ku = kushift(1);                *ten = tenshift(c);            }        }        else if (f == 2) {            *ku = kushift(3);            *ten = tenshift(c-32);        }        else {            *ku = kushift(f+1);            *ten = tenshift(c);        }    }    else if (f <= 19) {    /* Daiichi Suijun */        n = (f-8)*256+c;        *ku = kushift((n/94)+16);        *ten = tenshift((n%94)+1);    }    else {            /* Daini Suijun */        n = (f-20)*256+c;        *ku = kushift((n/94)+48);        *ten = tenshift((n%94)+1);    }    return;} /* compute_jis */#define    NJSUBS        33char *jsf_names[]={    "jsy", "jroma", "jhira", "jkata", "jgreek", "jrussian", "jkeisen",    "jka", "jkb", "jkc", "jkd", "jke", "jkf", "jkg", "jkh", "jki", "jkj",    "jkk", "jkl", "jkm", "jkn", "jko", "jkp", "jkq", "jkr", "jks", "jkt",    "jku", "jkv", "jkw", "jkx", "jky", "jkz"};int getjsubfont(char *s){    int jf;    if (s[0] == 'd' && (s[1] == 'm' || s[1] == 'g')) {        for (jf = 0; jf < NJSUBS; jf++) {            if (strncmp(&s[2], jsf_names[jf], strlen(jsf_names[jf])) == 0)                return jf+1;        }        return 0;    }    else      return 0;} /* getjsubfont *//* * VMS CODE */#if defined(VMS)long vmsseek(fp,n,dir)FILE *fp;long n;long dir;{    long k,m,pos,val,oldpos;    struct stat buffer;    for (;;) {                     /* loops only once or twice */        switch (dir) {            case 0:            /* from BOF */                    oldpos = vms_ftell(fp);                    k = n & 511;                    m = n >> 9;                    if (((*fp)->_cnt) && ((oldpos >> 9) == m)) {                        val = 0; /* still in */                        (*fp)->_ptr = ((*fp)->_base) + k;                        (*fp)->_cnt = 512 - k;                    }                    else {                        val = fseek(fp, m << 9, 0);                        if (val == 0) {                            (*fp)->_cnt = 0;                            (void) fgetc(fp);                            (*fp)->_ptr = ((*fp)->_base) + k;                            (*fp)->_cnt = 512 - k;                        }                    }                    return(val);            case 1: pos = vms_ftell(fp);                    if (pos == EOF)                        return (EOF);                    n += pos;                    dir = 0;                    break;            case 2: val = fstat(fileno(fp), &buffer);                    if (val == EOF)                        return (EOF);                    n += buffer.st_size - 1;                    dir = 0;                    break;            default : return (EOF);        }    }    /* NOTREACHED */} /* vmsseek */long vms_ftell(fp)FILE *fp;{    char c;    long pos;    long val;    if ((*fp)->_cnt == 0) {        c = fgetc(fp);        val = vms_ungetc(c, fp);        if (val != c)            return (EOF);    }    pos = ftell(fp);    if (pos >= 0)        pos += ((*fp)->_ptr) - ((*fp)->_base);    return (pos);} /* vms_ftell */long vms_ungetc(c,fp)char c;FILE *fp;{    if ((c == EOF) && feof(fp))        return (EOF);    if ((*fp)->_cnt >= 512)        return (EOF);    (*fp)->_cnt++;    (*fp)->_ptr--;    *((*fp)->_ptr) = c;    return (c);} /*vms_ungetc */#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -