- strcat (fname, ".vcg"); /* append the .vcg suffix */
- F = fopen (fname, "w"); /* open file for writing */
+
+ fname = malloc (len + 5 + strlen(suffix));
+ strncpy (fname, cp, len); /* copy the filename */
+ fname[len] = '\0'; /* ensure string termination */
+ /*strcpy (fname, cp); * copy the filename *
+ this produces wrong, too long strings in conjuction with the
+ jocca frontend. The \0 seems to be missing. */
+ strcat (fname, suffix); /* append file suffix */
+ strcat (fname, ".vcg"); /* append the .vcg suffix */
+ F = fopen (fname, "w"); /* open file for writing */