mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
merge: fix to use per-proc filenames rather than hardcoding them
The localized/utils/merge utility used hardcoded temporary filenames to do its thing. This prevented any Makefiles that called merge from enabling parallel builds in order avoid the file collisions that would result. Now we: - use filenames that embed the PID in them, making them unique per-process - place them in /tmp, rather than the current directory As a result, we can now re-enable parallel builds for localized app-defaults, config, and types.
This commit is contained in:
parent
f5c3c5d7a2
commit
3d217c6ed1
1 changed files with 28 additions and 19 deletions
|
@ -96,6 +96,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <nl_types.h>
|
#include <nl_types.h>
|
||||||
|
|
||||||
nl_catd catfile[2] = {NULL, NULL}; /* [0] for primary, [1] for default */
|
nl_catd catfile[2] = {NULL, NULL}; /* [0] for primary, [1] for default */
|
||||||
|
@ -108,21 +111,27 @@ int bs = 0;
|
||||||
int crt_line[3] = {0, 0, 1}; /* current line [0]: Primary message file */
|
int crt_line[3] = {0, 0, 1}; /* current line [0]: Primary message file */
|
||||||
/* [1]: Default message file */
|
/* [1]: Default message file */
|
||||||
/* [2]: Template file */
|
/* [2]: Template file */
|
||||||
|
char pFilename[PATH_MAX];
|
||||||
|
char dFilename[PATH_MAX];
|
||||||
|
pid_t procPID = 0;
|
||||||
|
|
||||||
void process_message ();
|
/* merge.c */
|
||||||
int get_char ();
|
void process_message(void);
|
||||||
void cat_open ();
|
int get_char(void);
|
||||||
int find_message ();
|
void cat_open(void);
|
||||||
int find_msg_in_file ();
|
int find_message(int msg);
|
||||||
void get_message ();
|
int find_msg_in_file(int msg, int file);
|
||||||
void fatal ();
|
void fatal(char *m, int line, int file);
|
||||||
void get_option ();
|
void get_option(int *argc, char *argv[]);
|
||||||
|
|
||||||
|
|
||||||
void main (int argc, char *argv [])
|
void main (int argc, char *argv [])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
procPID = getpid();
|
||||||
|
snprintf(pFilename, PATH_MAX, "/tmp/dt_pfile.%d.cat", procPID);
|
||||||
|
snprintf(dFilename, PATH_MAX, "/tmp/dt_dfile.%d.cat", procPID);
|
||||||
|
|
||||||
get_option(&argc, argv);
|
get_option(&argc, argv);
|
||||||
|
|
||||||
if(pfile == NULL)
|
if(pfile == NULL)
|
||||||
|
@ -171,8 +180,8 @@ void main (int argc, char *argv [])
|
||||||
if ( catfile[1] )
|
if ( catfile[1] )
|
||||||
catclose(catfile[1]);
|
catclose(catfile[1]);
|
||||||
|
|
||||||
unlink("./.dt_pfile.cat");
|
unlink(pFilename);
|
||||||
unlink("./.dt_dfile.cat");
|
unlink(dFilename);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
@ -234,25 +243,25 @@ int get_char (void)
|
||||||
*/
|
*/
|
||||||
void cat_open (void)
|
void cat_open (void)
|
||||||
{
|
{
|
||||||
char line[255];
|
char line[PATH_MAX];
|
||||||
|
|
||||||
unlink("./.dt_pfile.cat");
|
unlink(pFilename);
|
||||||
unlink("./.dt_dfile.cat");
|
unlink(dFilename);
|
||||||
|
|
||||||
if(pfile != NULL)
|
if(pfile != NULL)
|
||||||
{
|
{
|
||||||
sprintf(line,"gencat ./.dt_pfile.cat %s",pfile);
|
snprintf(line, PATH_MAX, "gencat %s %s", pFilename, pfile);
|
||||||
if ( system(line) != 0 )
|
if ( system(line) != 0 )
|
||||||
{
|
{
|
||||||
fatal("primary .tmsg file would not gencat\n",0,9);
|
fatal("primary .tmsg file would not gencat\n",0,9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catfile[0] = catopen("./.dt_pfile.cat",0);
|
catfile[0] = catopen(pFilename, 0);
|
||||||
|
|
||||||
if(dfile != NULL)
|
if(dfile != NULL)
|
||||||
{
|
{
|
||||||
sprintf(line,"gencat ./.dt_dfile.cat %s",dfile);
|
sprintf(line,"gencat %s %s", dFilename, dfile);
|
||||||
if ( system(line) != 0 )
|
if ( system(line) != 0 )
|
||||||
{
|
{
|
||||||
fatal("default .tmsg file would not gencat\n",0,9);
|
fatal("default .tmsg file would not gencat\n",0,9);
|
||||||
|
@ -260,10 +269,10 @@ void cat_open (void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catfile[1] = catopen("./.dt_dfile.cat",0);
|
catfile[1] = catopen(dFilename, 0);
|
||||||
|
|
||||||
/* if all fails */
|
/* if all fails */
|
||||||
if(catfile[0] == NULL && catfile[1] == NULL)
|
if (catfile[0] == NULL && catfile[1] == NULL)
|
||||||
fatal("Can't open message files.\n", 0, 9);
|
fatal("Can't open message files.\n", 0, 9);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue