我正在尝试找一些资源/教程来帮助我创建一个coccinelle脚本来查找结构声明并将它们从有序变为无序。
在我们的代码库中,我们使用了几百个结构。有人在定义的中间添加了一个成员,现在我需要更新数百个声明。默认值为0是好的,所以如果我将所有声明从顺序切换到无序,一切都很好,以及下一次更改的未来证明。
例如:
struct some_struct {
int blah;
int blah2;
}
// code is like this now.
struct some_struct ex1 = {
0,
1,
};
// Need script to change to this
struct some_struct ex2 = {
.blah1 = 0,
.blah2 = 1
}
有人能指出我正确的方向吗?
答案 0 :(得分:0)
Coccinelle教程: http://coccinelle.lip6.fr/papers.php
您也可以尝试邮件列表提问。这样的事情可能有用:
@@
constant C1, C2;
identifier i;
@@
struct some_struct i = {
+ .blah1 =
C1,
+ .blah2 =
C2,
};
答案 1 :(得分:0)
轻度测试:
ErrorException in 6141f213cedd055d619563849681212c line 16:
Trying to get property of non-object
in 6141f213cedd055d619563849681212c line 16
at HandleExceptions->handleError('8', 'Trying to get property of non-object', '/home/vagrant/Code/Family-laravel/storage/framework/views/6141f213cedd055d619563849681212c', '16', array('__path' => '/home/vagrant/Code/Family-laravel/storage/framework/views/6141f213cedd055d619563849681212c', '__data' => array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'family' => object(Family)), 'obLevel' => '1', '__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'family' => object(Family))) in 6141f213cedd055d619563849681212c line 16
at include('/home/vagrant/Code/Family-laravel/storage/framework/views/6141f213cedd055d619563849681212c') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/home/vagrant/Code/Family-laravel/storage/framework/views/6141f213cedd055d619563849681212c', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'family' => object(Family))) in CompilerEngine.php line 58
at CompilerEngine->get('/home/vagrant/Code/Family-laravel/resources/views/family/show.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'family' => object(Family))) in View.php line 135
at View->getContents() in View.php line 106
at View->renderContents() in View.php line 80
at View->render() in Response.php line 51
at Response->setContent(object(View)) in Response.php line 202
at Response->__construct(object(View)) in Router.php line 1225
at Router->prepareResponse(object(Request), object(View)) in ControllerDispatcher.php line 113
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(FamilyController), object(Route), object(Request), 'show') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\FamilyController', 'show') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54