~ubuntu-branches/ubuntu/wily/geany/wily

« back to all changes in this revision

Viewing changes to tagmanager/tm_workspace.c

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
                if (theWorkspace->global_tags)
83
83
                {
84
84
                        for (i=0; i < theWorkspace->global_tags->len; ++i)
85
 
                                tm_tag_free(theWorkspace->global_tags->pdata[i]);
 
85
                                tm_tag_unref(theWorkspace->global_tags->pdata[i]);
86
86
                        g_ptr_array_free(theWorkspace->global_tags, TRUE);
87
87
                }
88
88
                tm_work_object_destroy(TM_WORK_OBJECT(theWorkspace));
223
223
        {
224
224
                char *str = g_strdup_printf("#include \"%s\"\n", (char*)node->data);
225
225
                int str_len = strlen(str);
226
 
                size_t size;
227
226
 
228
 
                size = fwrite(str, str_len, 1, fp);
 
227
                fwrite(str, str_len, 1, fp);
229
228
                g_free(str);
230
 
                node = g_list_next (node);
 
229
                node = g_list_next(node);
231
230
        }
232
231
}
233
232
 
251
250
                }
252
251
                else
253
252
                {
254
 
                        size_t size;
255
 
                        size = fwrite(contents, length, 1, fp);
256
 
                        size = fwrite("\n", 1, 1, fp);  /* in case file doesn't end in newline (e.g. windows). */
 
253
                        fwrite(contents, length, 1, fp);
 
254
                        fwrite("\n", 1, 1, fp); /* in case file doesn't end in newline (e.g. windows). */
257
255
                        g_free(contents);
258
256
                }
259
257
                node = g_list_next (node);
260
258
        }
261
259
}
262
260
 
263
 
gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre_process,
264
 
        const char **includes, int includes_count, const char *tags_file, int lang)
 
261
static gchar *create_temp_file(const gchar *tpl)
 
262
{
 
263
        gchar *name;
 
264
        gint fd;
 
265
 
 
266
        fd = g_file_open_tmp(tpl, &name, NULL);
 
267
        if (fd < 0)
 
268
                name = NULL;
 
269
        else
 
270
                close(fd);
 
271
 
 
272
        return name;
 
273
}
 
274
 
 
275
gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
 
276
        int includes_count, const char *tags_file, int lang)
265
277
{
266
278
#ifdef HAVE_GLOB_H
267
279
        glob_t globbuf;
275
287
        GPtrArray *tags_array;
276
288
        GHashTable *includes_files_hash;
277
289
        GList *includes_files = NULL;
278
 
#ifdef G_OS_WIN32
279
 
        char *temp_file = g_strdup_printf("%s\\_%d_%ld_1.cpp", config_dir, getpid(), time(NULL));
280
 
        char *temp_file2 = g_strdup_printf("%s\\_%d_%ld_2.cpp", config_dir, getpid(), time(NULL));
281
 
#else
282
 
        char *temp_file = g_strdup_printf("%s/%d_%ld_1.cpp", config_dir, getpid(), time(NULL));
283
 
        char *temp_file2 = g_strdup_printf("%s/%d_%ld_2.cpp", config_dir, getpid(), time(NULL));
284
 
#endif
 
290
        gchar *temp_file = create_temp_file("tmp_XXXXXX.cpp");
 
291
        gchar *temp_file2 = create_temp_file("tmp_XXXXXX.cpp");
285
292
 
286
 
        if (NULL == theWorkspace || NULL == (fp = g_fopen(temp_file, "w")))
 
293
        if (NULL == temp_file || NULL == temp_file2 ||
 
294
                NULL == theWorkspace || NULL == (fp = g_fopen(temp_file, "w")))
287
295
        {
288
296
                g_free(temp_file);
289
297
                g_free(temp_file2);
376
384
         */
377
385
        if (pre_process != NULL)
378
386
        {
379
 
                int ret;
380
387
                command = g_strdup_printf("%s %s | grep -v -E '^\\s*(G_BEGIN_DECLS|G_END_DECLS)\\s*$' > %s",
381
388
                                                          pre_process, temp_file, temp_file2);
382
389
#ifdef TM_DEBUG
383
390
                g_message("Executing: %s", command);
384
391
#endif
385
 
                ret = system(command);
 
392
                system(command);
386
393
                g_free(command);
387
394
                g_unlink(temp_file);
388
395
                g_free(temp_file);
390
397
        else
391
398
        {
392
399
                /* no pre-processing needed, so temp_file2 = temp_file */
 
400
                g_unlink(temp_file2);
393
401
                g_free(temp_file2);
394
402
                temp_file2 = temp_file;
395
403
                temp_file = NULL;