Author: jfrederic.clere(a)jboss.com
Date: 2008-01-14 05:57:13 -0500 (Mon, 14 Jan 2008)
New Revision: 1276
Modified:
trunk/build/unix/util/jlibtool.c
Log:
Prevent copying the la file... cp would fail.
Modified: trunk/build/unix/util/jlibtool.c
===================================================================
--- trunk/build/unix/util/jlibtool.c 2008-01-13 17:17:21 UTC (rev 1275)
+++ trunk/build/unix/util/jlibtool.c 2008-01-14 10:57:13 UTC (rev 1276)
@@ -414,6 +414,16 @@
return newval;
}
+const char *getlast_count_chars(count_chars *cc)
+{
+ if (cc->num <= 0) {
+ return "";
+ }
+ else {
+ return cc->vals[cc->num-1];
+ }
+}
+
char *shell_esc(const char *str)
{
int in_quote = 0;
@@ -1772,7 +1782,7 @@
return rv;
}
}
- if (cmd_data->output_name) {
+ if (cmd_data->output_name && is_not_same(cmd_data)) {
append_count_chars(cctemp, cmd_data->arglist);
insert_count_chars(cctemp,
cmd_data->output_name,
@@ -1994,6 +2004,46 @@
}
}
+/* Check if we are installing the (.la) file on it self */
+int is_not_same(command_t *cmd_data)
+{
+ char *ptr;
+ const char *dir = getlast_count_chars(cmd_data->arglist);
+ struct stat sbi, sbo;
+ int rv;
+
+ rv = stat(dir, &sbi);
+ if (rv) {
+ return 1;
+ }
+ if (S_ISDIR(sbi.st_mode)) {
+ ptr = malloc(strlen(dir) + strlen(cmd_data->output_name) + 2);
+ strcpy(ptr, dir);
+ strcat(ptr, "/");
+ strcat(ptr, cmd_data->output_name);
+ }
+ else {
+ ptr = malloc(strlen(dir) + 1);
+ strcpy(ptr, dir);
+ }
+ rv = stat(ptr, &sbi);
+ if (rv) {
+ free(ptr);
+ return 1;
+ }
+ rv = stat(cmd_data->output_name, &sbo);
+ free(ptr);
+ if (rv) {
+ return 1;
+ }
+ if (memcmp(&sbi, &sbo, sizeof(sbi))) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
int main(int argc, char *argv[])
{
int rc;
Show replies by date