bool trytab(unsigned char *zbuf, scrbuf5 *scline) { long savlst; /* Former value of LSTLIN */ /* Look for -TO */ if (scline->toklen && !strncasecmp((char *)zbuf, "-TO", scline->toklen)) { if (lstlin <= 0) { fprintf(stderr, "-TO not allowed in this position"); GIVE_UP; } /* if (lstlin <= 0) */ savlst = lstlin; /* Will be overwritten by GETLIN */ if (!getlin(1, 0)) GIVE_UP; /* J back, error reported */ scline->decval = lstlin - savlst + 1; /* C/vert to a # of lines */ lstlin = savlst; /* Reinstate */ if (scline->decval > 0) return true; /* Finished - -TO successful */ fprintf(stderr, "-TO a previous line not allowed"); GIVE_UP; } /* if (scline->toklen && ... */ /* Not -TO, try for a Tab ID */ if (scline->toklen != 2 || toupper(zbuf[0]) != 'T') return false; return gettab(zbuf[1], true, &scline->decval, false); errlbl: fprintf(stderr, " or "); return 0; }
int main(int argc, char *argv[]) { int c, pos, spaces, currentt; settabs(argc - 1, ++argv); pos = spaces = currentt = 0; while ((c = getchar()) != EOF) { ++pos; currentt = gettab(pos); if (c == '\t') { spaces = 1; // we don't need to increment the position when we're at the tab // position if (pos % currentt) { spaces += currentt - (pos % currentt); pos += spaces - 1; } while (spaces-- > 0) putchar(' '); } else if (c == '\n') { putchar('\n'); pos = 0; resett(); } else putchar(c); } return 0; }
int main (int argc, char **argv) { int i; if (argc != 3) { fprintf (stderr, "Usage: mktab filename tabname\n"); exit (-1); } gettab (argv[1]); printf ("unsigned char %s [128] = {", argv[2]); for (i=128; i<256; ++i) { if (i % 8 == 0) printf ("\n\t"); printf ("0x%02x, ", tab[i]); } printf ("\n};\n"); return (0); }
void sort(t_env *e, int len) { int i; int x; int tmp; int *tab; i = -1; x = len; tmp = 0; tab = gettab(e->a->begin, len); while (x-- > 3) { ontop(e, tab[++i], lstlen(e->a)); push(e, 'b'); tmp++; if (verifsort(e->a)) break ; } if (len - tmp == 3) lsort(e); while (tmp-- > 0) push(e, 'a'); }
int FC_FUNC_(oraclesim_getdatahead, ORACLESIM_GETDATAHEAD) (OracleDbConnection **fdbconnid, char *ti, char *tf, int *net, int *var, int *nvar) { OracleDbConnection *dbconnid = *fdbconnid; int i; char *query; /* valori validi =1, mancanti =-1, inutilizzati per ora, ci pensa la query */ /* sb2 otab_ind, ovalp_ind, ovala_ind, oflag_ind; */ char odate[DATELEN], ovalc[CVALLEN], oflag[FLAGLEN]; int ostatid, ovarid; float ovalp, ovala; /* Eseguo l'estrazione per ottenere il nome della tabella, complicazione per colpa di CAELAMI */ if ((i = gettab(dbconnid, var, *nvar, net)) != 0) return i; /* Ricostruisco la richiesta dati con il nome della tabella ottenuto */ query = alloca(strlen(query1)+strlen(dbconnid->table)+strlen(query2)+ 10*(*nvar+1)+strlen(query3)+1); strcpy(query, query1); strcat(query, dbconnid->table); strcat(query, query2); if (*nvar > 1) { strcat(query, " IN ("); for (i=0; i < (*nvar); i++) { snprintf(query+strlen(query), 10, "%d", var[i]); if (i < (*nvar)-1) strcat(query, ","); } strcat(query, ")"); } else { strcat(query, " = "); snprintf(query+strlen(query), 10, "%d", *var); } strcat(query, query3); /* Preparo l'estrazione dati */ checkerr(dbconnid, OCIStmtPrepare(dbconnid->stmthp, dbconnid->errhp, (text *) query, (ub4) strlen(query), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)); checkerr(dbconnid, OCIBindByName(dbconnid->stmthp, &dbconnid->bnd1p, dbconnid->errhp, (text *) ":ti", -1, (dvoid *) ti, DATELEN, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)); checkerr(dbconnid, OCIBindByName(dbconnid->stmthp, &dbconnid->bnd2p, dbconnid->errhp, (text *) ":tf", -1, (dvoid *) tf, DATELEN, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)); checkerr(dbconnid, OCIBindByName(dbconnid->stmthp, &dbconnid->bnd3p, dbconnid->errhp, (text *) ":net", -1, (dvoid *) net, (sword) sizeof(*net), SQLT_INT, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)); /* definisco l'uscita */ datadefine(dbconnid, odate, DATELEN, &ostatid, &ovarid, &ovalp, &ovala, ovalc, oflag, CVALLEN, FLAGLEN); return countrows(dbconnid); }