@@ -72,37 +72,32 @@ PrintStringIntoString::execute()
7272 std::string str;
7373
7474 std::vector<char > buffer (256 );
75- bool lastport = false ;
76-
77-
78- auto stringH = getOptionalInput (Format);
79-
75+ bool lastport = false ;
76+ auto stringH = getOptionalInput (Format);
8077 auto state = get_state ();
8178
8279 // check for port input and in none use gui input
8380 if (stringH && *stringH)
8481 {
85- state -> setValue (FormatString, (*stringH) -> value ());
82+ state-> setValue (FormatString, (*stringH)-> value ());
8683 }
87- format = state -> getValue (FormatString).toString ();
88-
84+ format = state->getValue (FormatString).toString ();
8985
90- // Get the dynamic handles
9186 auto stringsH = getOptionalDynamicInputs (Input);
9287
9388
9489 if (needToExecute ())
9590 {
9691 size_t i = 0 ;
97- while (i < format.size ())
92+ while (i < format.size ())
9893 {
9994 if (format[i] == ' %' )
10095 {
10196 if (i == format.size ()-1 )
10297 {
10398 error (" Improper format string '%' is last character" );
10499 return ;
105- }
100+ }
106101
107102 if (format[i+1 ] == ' %' )
108103 {
@@ -125,34 +120,33 @@ PrintStringIntoString::execute()
125120
126121 std::string fstr = format.substr (i,j-i+1 );
127122
123+ if ((format[j] == ' s' )||(format[j] == ' S' )||(format[j] == ' c' )||(format[j] == ' C' ))
128124 {
129- str = " " ;
130- if (lastport == false )
131125 {
132- if (inputport == stringsH.size ())
133- {
134- lastport = true ;
135- }
136- else
126+ str = " " ;
127+ if (!lastport)
137128 {
138- if (stringsH. size () == static_cast < size_t >(inputport ))
129+ if (inputport == stringsH. size ( ))
139130 {
140131 lastport = true ;
141132 }
142133 else
143134 {
144- currentstring = stringsH[inputport]; inputport++;
145- if (currentstring)
135+ if (stringsH.size () == static_cast <size_t >(inputport))
136+ {
137+ lastport = true ;
138+ }
139+ else
146140 {
147- str = currentstring->value ();
141+ currentstring = stringsH[inputport++];
142+ if (currentstring)
143+ {
144+ str = currentstring->value ();
145+ }
148146 }
149147 }
150148 }
151149 }
152- }
153-
154- if ((format[j] == ' s' )||(format[j] == ' S' )||(format[j] == ' c' )||(format[j] == ' C' ))
155- {
156150 // We put the %s %S back in the string so it can be filled out lateron
157151 // By a different module
158152
@@ -209,7 +203,7 @@ PrintStringIntoString::execute()
209203 output += format[i++];
210204 }
211205 }
212-
206+
213207 StringHandle handle (new String (output));
214208 sendOutput (Output, handle);
215209 }
0 commit comments