3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) Francois Vogel
5 * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
7 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
15 /*--------------------------------------------------------------------------*/
16 /* sciprint_full function */
17 /*--------------------------------------------------------------------------*/
18 /* sciprint geared towards long strings (>MAXPRINTF) */
19 /* the long string is splitted in elements of length equal to the number of columns */
21 /*--------------------------------------------------------------------------*/
25 #include "sciprint_full.h"
28 #include "localization.h"
29 #include "../../shell/includes/scilines.h"
30 /*--------------------------------------------------------------------------*/
32 #define vsnprintf _vsnprintf
34 /*--------------------------------------------------------------------------*/
35 /* MAXCHARSSCIPRINT_FULL is for sciprint_full - more than this gets truncated */
36 #define MAXCHARSSCIPRINT_FULL 5000
37 /*--------------------------------------------------------------------------*/
38 void sciprint_full(char *fmt,...)
43 char *split_s_buf=NULL;
48 s_buf=MALLOC(sizeof(char)*(MAXCHARSSCIPRINT_FULL+1));
49 if (s_buf == (char *) 0)
51 sciprint(_("%s: No more memory.\n"),"sciprint_full");
55 /* number of columns as set by command lines() */
56 colwidth = getColumnsSize();
58 split_s_buf=MALLOC(sizeof(char)*(colwidth+1));
59 if (split_s_buf == (char *) 0)
61 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);
87 strncpy(split_s_buf,s_buf+p_s,colwidth-1);
88 split_s_buf[colwidth]='\0';
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';
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);
104 if (s_buf){FREE(s_buf);s_buf=NULL;}
105 if (split_s_buf){FREE(split_s_buf);split_s_buf=NULL;}
108 /*--------------------------------------------------------------------------*/