Howdy, While cleaning up my nfstrace program, I came to the following: fbt:nfs:nfs3_symlink:return / self->symlinkts && self->ok / { this->join1 = strjoin(stringof(self->linkfromdir), "/"); this->join2 = strjoin(this->join1, stringof(self->symlinkfrom)); this->join3 = strjoin(this->join2, " -> "); this->join4 = strjoin(this->join3, stringof(self->linktodir)); this->join5 = strjoin(this->join4, "/"); this->join6 = strjoin(this->join5, stringof(self->symlinkto)); printf("%-10s %-12s %-8s %-7d %-6s %-35s\n", execname, probefunc, "physical", timestamp - self->symlinkts, "N/A", this->join6); } Would it be possible to add an operator to printf to allow you to concatentate strings directly from printf? I am not sure what folks think about this from a style perspective, but I personally think that concatenating within printf makes things a bit more readable: printf("%-10s %-12s %-8s %-7d %-6s %-35s\n", execname, probefunc, "physical", timestamp - self->symlinkts, "N/A", self->linkfromdir . "/" . self->symlinkfrom . " ->" . self->linktodir . "/" . self->symlinkto); If there is an operator to do this, please let me know. I couldn''t find one in the output formatting chapter of the DTrace user guide. Thanks, - Ryan -- UNIX Administrator http://daemons.net/~matty
Michael Shapiro
2006-May-04 23:25 UTC
[dtrace-discuss] Concatenation operator in print statments?
> > Howdy, > > While cleaning up my nfstrace program, I came to the following: > > fbt:nfs:nfs3_symlink:return > / self->symlinkts && self->ok / > { > this->join1 = strjoin(stringof(self->linkfromdir), "/"); > this->join2 = strjoin(this->join1, stringof(self->symlinkfrom)); > this->join3 = strjoin(this->join2, " -> "); > this->join4 = strjoin(this->join3, stringof(self->linktodir)); > this->join5 = strjoin(this->join4, "/"); > this->join6 = strjoin(this->join5, stringof(self->symlinkto)); > > printf("%-10s %-12s %-8s %-7d %-6s %-35s\n", execname, > probefunc, > "physical", > timestamp - self->symlinkts, > "N/A", > this->join6); > } > > Would it be possible to add an operator to printf to allow you to > concatentate strings directly from printf? I am not sure what folks > think about this from a style perspective, but I personally think that > concatenating within printf makes things a bit more readable: > > printf("%-10s %-12s %-8s %-7d %-6s %-35s\n", execname, > probefunc, > "physical", > timestamp - self->symlinkts, > "N/A", > self->linkfromdir . "/" . > self->symlinkfrom . " ->" . > self->linktodir . "/" . > self->symlinkto); > > If there is an operator to do this, please let me know. I couldn''t find > one in the output formatting chapter of the DTrace user guide. > > Thanks, > - RyanThere is no operator to do this at present. It is conceivable to add one in the sense that it''s just syntactic sugar on top of the strjoin() function, but we tried to avoid going overboard on syntactic sugar in D. For one thing, it makes adhering to the intricacies of the C grammar difficult :) In general, if things are every now and then I''d prefer you use the functions. If something keeps coming up and is very annoying and overcomplex to write we can consider adding syntactic sugar to make it easier. -Mike -- Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/