@@ -130,12 +130,12 @@ static PyTypeObject StdoutType = {
130130 nullptr , /* tp_new */
131131};
132132
133- PyModuleDef embmodule = {
133+ static PyModuleDef embmodule = {
134134 PyModuleDef_HEAD_INIT,
135135 " emb" ,
136- 0 ,
136+ nullptr ,
137137 -1 ,
138- 0 ,
138+ nullptr ,
139139};
140140
141141// Internal state
@@ -144,13 +144,13 @@ struct StreamPair
144144 PyObject* saved = nullptr ;
145145 PyObject* current = nullptr ;
146146};
147- std::map<std::string, StreamPair> streams;
147+ static std::map<std::string, StreamPair> streams;
148148
149149PyMODINIT_FUNC PyInit_emb (void )
150150{
151151 StdoutType.tp_new = PyType_GenericNew;
152152 if (PyType_Ready (&StdoutType) < 0 ) {
153- return 0 ;
153+ return nullptr ;
154154 }
155155
156156 PyObject* m = PyModule_Create (&embmodule);
@@ -161,20 +161,20 @@ PyMODINIT_FUNC PyInit_emb(void)
161161 return m;
162162}
163163
164- void set_stream (const std::string& stream, stdout_write_type write)
164+ static void set_stream (const std::string& stream, stdout_write_type write)
165165{
166166 auto & stream_pair = streams[stream];
167167 if (stream_pair.current == nullptr ) {
168168 stream_pair.saved = PySys_GetObject (stream.c_str ());
169- stream_pair.current = StdoutType.tp_new (&StdoutType, 0 , 0 );
169+ stream_pair.current = StdoutType.tp_new (&StdoutType, nullptr , nullptr );
170170 }
171171
172172 Stdout* impl = reinterpret_cast <Stdout*>(stream_pair.current );
173- impl->write = write;
173+ impl->write = std::move ( write) ;
174174 PySys_SetObject (stream.c_str (), stream_pair.current );
175175}
176176
177- void reset_streams ()
177+ static void reset_streams ()
178178{
179179 for (auto & [stream, stream_pair] : streams) {
180180 if (stream_pair.saved != nullptr ) {
@@ -323,7 +323,7 @@ void PythonCmdInputWidget::init()
323323 return ;
324324 }
325325 s.erase (s.find_last_not_of (" \r\n " ) + 1 );
326- s.erase (s.find_last_not_of (" \n " ) + 1 );
326+ s.erase (s.find_last_not_of (' \n ' ) + 1 );
327327 if (s.empty ()) {
328328 return ;
329329 }
@@ -340,7 +340,7 @@ void PythonCmdInputWidget::init()
340340 return ;
341341 }
342342 s.erase (s.find_last_not_of (" \r\n " ) + 1 );
343- s.erase (s.find_last_not_of (" \n " ) + 1 );
343+ s.erase (s.find_last_not_of (' \n ' ) + 1 );
344344 if (s.empty ()) {
345345 return ;
346346 }
0 commit comments