2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) Francois Vogel
4 * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 /*--------------------------------------------------------------------------*/
15 /* sciprint_full function */
16 /*--------------------------------------------------------------------------*/
17 /* sciprint geared towards long strings (>MAXPRINTF) */
18 /* the long string is splitted in elements of length equal to the number of columns */
20 /*--------------------------------------------------------------------------*/
24 #include "sciprint_full.h"
27 #include "localization.h"
29 /*--------------------------------------------------------------------------*/
31 #define vsnprintf _vsnprintf
33 /*--------------------------------------------------------------------------*/
34 /* MAXCHARSSCIPRINT_FULL is for sciprint_full - more than this gets truncated */
35 #define MAXCHARSSCIPRINT_FULL 5000
36 /*--------------------------------------------------------------------------*/
37 void sciprint_full(char *fmt, ...)
42 char *split_s_buf = NULL;
47 s_buf = MALLOC(sizeof(char) * (MAXCHARSSCIPRINT_FULL + 1));
48 if (s_buf == (char *) 0)
50 sciprint(_("%s: No more memory.\n"), "sciprint_full");
54 /* number of columns as set by command lines() */
55 colwidth = getColumnsSize();
57 split_s_buf = MALLOC(sizeof(char) * (colwidth + 1));
58 if (split_s_buf == (char *) 0)
60 sciprint(_("%s: No more memory.\n"), "sciprint_full");
67 #if defined(linux) || defined(_MSC_VER)
68 count = vsnprintf (s_buf, MAXCHARSSCIPRINT_FULL - 1, fmt, ap );
71 s_buf[MAXCHARSSCIPRINT_FULL - 1] = '\0';
74 (void )vsprintf(s_buf, fmt, ap );
79 lstr = (int) strlen(s_buf);
83 sciprint("%s", s_buf);
87 strncpy(split_s_buf, s_buf + p_s, colwidth - 1);
88 split_s_buf[colwidth] = '\0';
89 p_s = p_s + colwidth - 1;
90 sciprint("%s", split_s_buf);
92 while (p_s + colwidth - 1 < (int)lstr)
94 strncpy(split_s_buf, s_buf + p_s, colwidth - 1);
95 split_s_buf[colwidth] = '\0';
96 p_s = p_s + colwidth - 1;
97 sciprint(_(" (cont'd) %s\n"), split_s_buf);
99 strncpy(split_s_buf, s_buf + p_s, lstr - p_s);
100 split_s_buf[lstr - p_s] = '\0';
101 sciprint(_(" (end) %s\n"), split_s_buf);
116 /*--------------------------------------------------------------------------*/