Exemplo n.º 1
0
static int 
set_locale_with_workaround (int langid, const char *lcode)
{
    char *test = setlocale(LC_ALL, lcode);

# ifndef WIN32    
    if (test == NULL) {
	char lfix[32];

	sprintf(lfix, "%s.UTF-8", lcode);
	test = setlocale(LC_ALL, lfix);
    }
# endif

    if (test != NULL) {
	fprintf(stderr, "setlocale: '%s' -> '%s'\n", lcode, test);
	if (strcmp("_File", _("_File")) == 0) {
	    const char *langstr;
	    char tmp[64];
	    
	    langstr = lang_string_from_id(langid);
	    sscanf(langstr, "%s", tmp);
	    gretl_lower(tmp);
	    gretl_setenv("LANGUAGE", tmp);
	}
    }

    return test == NULL;
}
Exemplo n.º 2
0
static void panelvar_candidates (GList *vlist, int *uid, int *tid)
{
    GList *list = vlist;
    const char *vname;
    char vtest[VNAMELEN];
    int i;

    *uid = *tid = -1;

    for (i=0; list != NULL; i++) {
	vname = (const char *) list->data;
	strcpy(vtest, vname);
	gretl_lower(vtest);
	if (*tid < 0) {
	    if (!strcmp(vtest, "time") || 
		!strcmp(vtest, "year") ||
		!strcmp(vtest, "period")) {
		*tid = i;
	    }
	}
	if (*uid < 0) {
	    if (!strcmp(vtest, "unit") ||
		!strcmp(vtest, "group") ||
		!strcmp(vtest, "country") ||
		!strcmp(vtest, "id")) {
		*uid = i;
	    }
	}
	if (*uid >= 0 && *tid >= 0) {
	    break;
	}
	list = list->next;
    }

    /* if we didn't succeed above, just ensure a non-conflicting
       assignment to uidx and tidx */

    if (*uid < 0) {
	if (*tid < 0) {
	    *uid = 0;
	    *tid = 1;
	} else {
	    *uid = (*tid == 0)? 1 : 0;
	}
    } else if (*tid < 0) {
	*tid = (*uid == 0)? 1 : 0;
    }
}
Exemplo n.º 3
0
static gchar *gpage_switch_compiler (int term)
{
    gchar *orig = g_strdup(latex);
    char *p, tmp[MAXSTR];
    char test[4];
    int len0, have_pdf;

    strcpy(tmp, latex);
    p = strrchr(tmp, SLASH);
    if (p == NULL) {
	len0 = 0;
	p = tmp;
    } else {
	len0 = p - tmp + 1;
	p++;
    }

    *test = '\0';
    strncat(test, p, 3);
    gretl_lower(test);

    have_pdf = (strcmp(test, "pdf") == 0);

    if (term == GP_TERM_PDF && !have_pdf) {
	/* switch to pdflatex */
	*latex = '\0';
	strncat(latex, tmp, len0);
	strncat(latex, "pdf", 3);
	strcat(latex, p);
    } else if (term != GP_TERM_PDF && have_pdf) {
	/* switch to plain latex */
	*latex = '\0';
	strncat(latex, tmp, len0);
	strcat(latex, p + 3);
    }

    return orig;
}
Exemplo n.º 4
0
void set_gretl_charset (void)
{
    const char *charset = NULL;
    char gretl_charset[32];

#ifdef MAC_NATIVE
    /* FIXME - why is this necessary? */
    native_utf8 = 1;
#else
    native_utf8 = g_get_charset(&charset);
#endif

    if (native_utf8) {
	set_stdio_use_utf8();
    }

    *gretl_charset = '\0';

    if (!native_utf8 && charset != NULL && *charset != '\0') {
	char *p;

	strncat(gretl_charset, charset, 31);
	gretl_lower(gretl_charset);
	p = strstr(gretl_charset, "iso");
	if (p != NULL) {
	    char numstr[6] = {0};

	    while (*p && !isdigit((unsigned char) *p)) p++;
	    strncat(numstr, p, 4);
	    gretl_cset_maj = atoi(numstr);
	    if (strlen(p) > 4) {
		p += 4;
		while (*p && !isdigit((unsigned char) *p)) p++;
		gretl_cset_min = atoi(p);
	    }
	    
	    if (gretl_cset_maj < 0 || gretl_cset_maj > 9000) {
		gretl_cset_maj = gretl_cset_min = 0;
	    } else if (gretl_cset_min < 0 || gretl_cset_min > 30) {
		gretl_cset_maj = gretl_cset_min = 0;
	    }
	} 
#ifdef WIN32
	if (p == NULL) {
	    sscanf(gretl_charset, "cp%d", &gretl_cpage);
	}
#endif
    }

#ifdef WIN32
    fprintf(stderr, "codepage = %d\n", gretl_cpage);
    if (gretl_cpage != 1250) {
	char *e = getenv("GRETL_CPAGE");

	if (e != NULL && !strcmp(e, "1250")) {
	    gretl_cpage = 1250;
	    fprintf(stderr, "revised codepage to 1250\n");
	}
    }
#endif
}