星期一 五月 25, 2009

Solaris Nevada will be "Changing Truetype Fonts path to make NV and OpenSolaris same". Post simple description one-page here for discussion.  It's automatic approved now. If you have any comments, please let me know asap.

星期一 五月 04, 2009

转载时请以超链接形式标明文章原始出处和作者信息.  :
http://blogs.sun.com/weixue/entry/build_open_x_on_solaris

OpenSolaris Project: Fully Open X Project is fully X project which include X library and application for  Opensolaris. The Fully Open X Project (FOX) will create a public Mercurial gate on opensolaris.org containing a merge of these three source bases:

  • the current OpenSolaris X code drops published by the Sun X team
  • the Xorg SPARC driver sources created by Martin Bochnig for Martux
  • the full X11R7.2 source builds created by Moinak Ghosh for Belenix
Build fox-gate: please see:  http://opensolaris.org/os/project/fox/build_inst/

星期四 四月 30, 2009

转载时请以超链接形式标明文章原始出处和作者信息
http://blogs.sun.com/weixue/entry/tip_differece_master_pty_regards

During investigation Opensolaris bug 6824625. The root cause is the different result of calling tcsetattr() for pty on Solaris and Linux.
Solaris and Linux treat slave pty differently.
For opening pty (Pseudo Terminal), there have two steps, open master device and slave device sequently. On Solaris, master pty device is not regarded as a terminal device. it regard slave device as a terminal device only.
But On Linux(I tested on Ubuntu), both master and slave devices are regarded as terminal devices.

So, tcsetattr() can work for both master and slave device on Linux. But, tcsetattr() can only work for slave pty device on Solaris. You can also use isatty() to tests if file descriptor is associated with terminal device .

It's a useful tip for porting terminal application between Solaris and Linux.

A piece of code for your reference, how to open pty: You can see that ioctl() only apply to slave device on Solaris(in macro #ifdef __sun).

FYI.

The Open Group Base Specifications : General Terminal Interface.
Concept of pty, tty..(in Chinese)

星期五 四月 24, 2009

转载时请以超链接形式标明文章原始出处和作者信息
http://blogs.sun.com/weixue/entry/which_terminal_emulator_do_you

During doing many terminal(emulator) evaluation, I found there are so many terminal emulator. And most of these support i18n feature. That means you can use it to display of input international languages character. Currently, the goal of evaluation is to weight which terminal should be high priority to be integrated in Opensolaris. Of course, there are some terminal emulator are not be listed. such like iterm, fbterm. If you need, I'll add them. Please see FOSS terminal evaluation. Hope you could leave comment to let me know which terminal is you favorate and which terminal you would like to be integrated in Opensolaris.

Your comments would be appraciated. Btw, if any xi18n support terminal I haven't listed , please let me know!.Thanks!

星期一 四月 13, 2009

本该在上周发的,一首Deep love song。。。 这首歌还有两个版本Bye Bye (Feat. Akon & Lil Wayn),Bye Bye Feat.Jay-Z。不过还是原来这个版本更感人。

This is for my peoples who just lost somebody
这首歌献给那些刚刚失去某人的人
Ya best friend ya baby
你最好的朋友、你的宝贝
Ya man or ya lady
你的男人或者你的女人
Put ya hand way up high
高高举起你的双手
We will never say bye
我们永远不会说再见
Mamas daddys sisters brothers
妈妈爸爸兄弟姐妹
Friends and cousins
朋友和堂(表)兄弟姐妹
This is for my peoples who lost their grandmothers
这首歌献给那些失去祖母的人
Lift ya head to the sky
抬起头仰望天空
Cause we will never say bye
因为我们永远不会说再见
As a child there were them times
孩提时,有他们相伴的时光
I didn't get it but you kept me in line
我还不懂事,但你将我紧紧记在脑海里
I didn't know why you didn't show up sometimes
我不知道为什么有些时候你不在
On Sunday mornings and I missed you
星期日的早上我十分想念你
But I'm glad we talked through
但我很开心我们谈了许多
All them grown folk things
他们都长成了普通人
Separation brings
带来了分离
You never let me know it
你从不让我知道这些
You never let it show because
你从不让他在我眼前出现
You loved me and obviously
因为你很爱我
There's so much more left to say
还有好多话想说
If you were with me today
你今天仍和我同在
Face to face
面对面的
Never knew I could hurt like this
从没想过我会如此痛苦
And everyday life goes on I
每天生活都继续着
Wish I could talk to you for a while
我希望我能和你聊一会儿
Miss you but I try not to cry
我好想念你但是我努力不让自己哭泣
As time goes by
时间流逝
And it's true that you've Reached a better place
事实上,你已经到了一个更加美好的地方
Still I'd give the world
然而我来到这个世界上
To see your face (bye)
看见你的脸庞
And be right here next to you (bye)
就在你的身边
But it's like you're gone too soon (bye)
但似乎你离开的太快了
Now the hardest thing to do
现在最难受的事情
Is say bye bye
是和你说再见
Bye bye bye bye bye bye
Bye bye bye bye bye bye
Bye bye bye bye bye bye
Bye bye
And you never got a chance
你没有机会
To see how good I done
来看我做的有多么棒
And you never got to see me
你从没有看到我
Back at number one
重新成为第一
I wish that you were here
我希望你能在这儿
To celebrate together
和我一起庆祝
I wish that we could spend
我希望我们能一起度过
The holidays together
整个假期
I remember when you used to
我记得你曾经
Tuck me in at night
在夜晚给我塞好被子
With the teddy bear you gave me
你给我的小熊
That I held so tight
我紧紧抱在怀里
I thought you were so strong
我曾以为你很强大
You'd make it through whatever
你克服了很多困难
It's so hard to accept the fact You're gone forever
很难接受你永远离开的现实
Never knew I could hurt like this
从没想过我会如此痛苦
And everyday life goes on I
每天生活都继续着
Wish I could talk to you for a while
我希望我能和你聊一会儿
Miss you but I try not to cry
我好想念你但是我努力不让自己哭泣
As time goes by
时间流逝
And it's true that you've
Reached a better place
事实上,你已经到了一个更加美好的地方
Still I'd give the world
然而我来到这个世界上
To see your face (bye)
看见你的脸庞
And be right here next to you (bye)
就在你的身边
But it's like you're gone too soon (bye)
但似乎你离开的太快了
Now the hardest thing to do
现在最难受的事情
Is say bye bye
是和你说再见
Bye bye bye bye bye bye
Bye bye bye bye bye bye
Bye bye bye bye bye bye
Bye bye
This is for my peoples who just lost somebody
这首歌献给那些刚刚失去某人的人
Ya best friend ya baby
你最好的朋友、你的宝贝
Ya man or ya lady
你的男人或者你的女人
Put ya hand way up high
高高举起你的双手
We will never say bye
我们永远不会说再见
Mamas daddys sisters brothers
妈妈爸爸兄弟姐妹
Friends and cousins
朋友和堂(表)兄弟姐妹
This is for my peoples who lost their grandmothers
这首歌献给那些失去祖母的人
Lift ya head to the sky
抬起头仰望天空
Cause we will never say bye
因为我们永远不会说再见
Never knew I could hurt like this
从没想过我会如此痛苦
And everyday life goes on I
每天生活都继续着
Wish I could talk to you for a while
我希望我能和你聊一会儿
Miss you but I try not to cry
我好想念你但是我努力不让自己哭泣
As time goes by
时间流逝
And it's true that you've
Reached a better place
事实上,你已经到了一个更加美好的地方
Still I'd give the world
然而我来到这个世界上
To see your face (bye)
看见你的脸庞
And be right here next to you (bye)
就在你的身边
But it's like you're gone too soon (bye)
但似乎你离开的太快了
Now the hardest thing to do
现在最难受的事情
Is say bye bye
是和你说再见

星期二 四月 07, 2009

During investigate Opensolaris bug 6824625(And 6728611 ) . There is a issue about macro Xorg, the Xorg  seems to be a remnant of old Imake world.  For example, in app/luit/sys.c, it always use #ifdef SVR4 as switch.  but on Solaris there is no pre-define for "SVR4", only pre-define "__SVR4". (check : CC -xdumpmacros -c dummy.c). For resolve this issue, X team support a header file <X11/Xosdefs.h>. So please include this header file in the program which need use CC or gcc pre-define macros.  In Xosdefs.h:

#ifdef sun
/* Imake configs define SVR4 on Solaris, but cc & gcc only define __SVR4
  * This check allows non-Imake configured programs to build correctly.
  */
#if defined(__SVR4) && !defined(SVR4)
#define SVR4 1
#endif
#endif
This issue also be discussed in xorg mail-list early (Some portabity issues). Alan gave the solution on Solaris.

星期五 三月 27, 2009

Add two widgets to my sider bar. 

1. Forecast weather

It can generate a cool flash of weather forecast. You can customize the location which you care. I put Beijing China here.

2. Music player

It lets you play any web-based playlist Select this widget and then click on the edit dropdown to search for a new playlist or enter the URL of one of your playlists. You can also enter the URL of one of your own MP3s. Additionally you can configure the shape, size, visualizations, and more.

I turn autoplay off. You can click play or the song you like to play it. 

星期五 三月 20, 2009

转载时请以超链接形式标明文章原始出处和作者信息
http://blogs.sun.com/weixue/entry/how_to_complile_fetion_for

在Opensolaris上使用pidgin这个即时通信客户端,可以支持很多的协议。但是国内流行的QQ和飞信在最新官方的Opensoalris发布版里都没有加入这两个协议的支持。本文讲述如何在pidgin中使用飞信的扩展。这里是编译好的飞信扩展libfetion.so,(感谢SunYong同学编译的release版:))下载后放到 /usr/lib/purple-2 目录下,重新启动pidgin即可。

下面说说如何自己动手编译飞信fetion,首先在Opensoalris中搭建编译环境,可参考这篇文章。(如果你觉得这篇难看懂,就把Sunstudio装上先,然后装下列包pkg install ss-dev SUNWxwinc SUNWxorg-headers SUNWgnome-common-devel SUNWperl-xml-parser SUNWiconv-unicode SUNWiconv-extra SUNWgit SUNWgm4 SUNWgnu-gettext SUNWperl-xml-parser SUNWGlib SUNWgnu-automake-110 SUNWaconf

编译的步骤:

下载 fetion protocol,将fetion目录整个拷贝到:
../libpurple/protocols

修改:
../libpurple/protocols/Makefile.in and Makefile.am
在DIST_SUBDIRS中增加fetion

修改:
configure.ac,
照着qq的位置加入fetion

编译:
aclocal
autoconf
automake -a -f -c

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --disable-binreloc --enable-gnutls=no --with-nss-includes=/usr/include/mps --with-nss-libs=/usr/lib/mps --with-nspr-includes=/usr/include/mps --with-nspr-libs=/usr/lib/mps --enable-gnome-keyring --enable-gevolution --enable-cap --disable-meanwhile --disable-nm --disable-consoleui --with-perl-lib=vendor --disable-nss CC=/opt/SUNWspro/bin/cc CXX=/opt/SUNWspro/bin/CC

make


星期四 三月 19, 2009

It reported in Opensoalris forums that "Problem with b108 and ssh -X". Because Opensoalaris already move to Xorg's X window component, so the X fonts naming style of S10 is not compatibility with it. So, when you login to remote S10 machine from locale Opensolaris, you may see message like:
> font missing: KSC5601.1992-3 for Window
> font missing: TIS620.2533-0 for Window
> font missing: ISO8859-6 for Window
> font missing: ISO8859-8 for Window
> font missing: SUN.UNICODE.INDIA-0 for Window


Please use Opensolaris/lastest Nevada as remote machine to avoid the error.
Also, when I run
ssh -X S10_machine -l account /usr/bin/gnome-terminal
error message is showed as following.
The program 'gnome_segv' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 255 error_code 2 request_code 148 minor_code 3)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)


I'm not sure the reason, it looks also because of incompatibility.

最新提交给Bigadmin的关于字体知识的文章上线了。
谈谈字体那些事(第一部分):介绍根据外形字体分类
谈谈字体那些事(第二部分):介绍根据字体数据存贮格式分类
谈谈字体那些事(第三部分):介绍字体的大小的知识


计划继续将这个系列写下去。包扩介绍字体的使用,和字体是如何显示和工作的。

星期一 三月 16, 2009

On Mar.15, another InstallFest at BeiYou University HongFu brach. Some pictures FYI.

Slide :

星期一 三月 09, 2009

Last Sunday (Mar. 8) afternoon, Techgirls Group from BLUG and BOSS (Beiyou University OSS society) in Beiyou University (BUPT) co-organizing a Girls Installfest. But this time is NOT girl only activity. ;). I received invistation to be a speaker and help to the participator to install OpenSolaris. It's good opportunity to promote OpenSolaris the community.

Almost all the participants had no any experience of using Solaris. Even it is the first for a lot of them to hear of Solaris. At the beginning,I did a twenty-minutes presentation to introduce the OpenSolaris. Then, Forrest Wu, who have been work on ZFS project as a DP for more than three years, also give a very short presentation to introduce ZFS. I believe the presentations are very helpful to attract the participated students to install OpenSolaris. Especially for ZFS. :)  This afternoon, Forrest and I helped more than ten students installed OpenSolaris (dual boot or in virtualbox) successfully.

This is a successful activity. I summarized some concern of students and issue we encountered. I think these issues/concern deserve our attention and improvement in order to attract more users.

1. Parted disk - Most of student have a WindowsXP/Vista OS, so the first thing to install dual root system is disk partition. It's seems only mast partition could be recognized by installer.

2. How much size ZFS snapshot need? very small, even you can ignore it.

3. Where I can download and upgrade software? Besides default IPS server, IPS server mirror available for China : http://pkg.unix-center.net. Futher more:
blastwave (preferred)               http://blastwave.network.com:10000/
sunfreeware                         http://pkg.sunfreeware.com:9000/

4. Instance message client application: Can I use qq and fetion? Yes, pidgin support qq and fetion protocol modules. But currently, you need compile them by yourself.   I have to say that these two instance message tools are very very popular in China. The office number by Tencent, there are 4 hundred million registered users for qq. And fetion is the fastest-growing instant messaging tools in China currently which delivered by China Mobile. So if these two modules could be integrated by default for China user, it will make OpenSolaris more closed with China user.

5. Driver, as you know this is old problem, we are resolving them step by step. The good thing is that we can see most major device drive we supported. And good news is more and more device drivers will be supported in the future.

Here some pictures I'd like share with you.


There are two text files, each are 10 million lines, the size of the text file at about 100M. Now need to know that the two documents there is cross-check the number of lines, in other words, we want to know the the number of lines simultaneously in the two documents exist. Each text file here is unique, so they do not have any duplicate rows. Python set could do this very easy and higher efficient than shell, awk.
#!/usr/bin/python
a = set(open(”data.uniq.1″))
b = set(open(”date.uniq.2″))
print len(a; b)
Here I find a blog in Chinese also description this tips

星期四 二月 26, 2009

Today is Dragon Heads-rasing Day (二月二龙抬头). Folowing is information about it which forward from BaiduZhidao.

Dragon Heads-raising Day falls on the second day of the second lunar month, which is a traditional festival. In "Imperial Capital Accounts About Seasons", Pan Rongbi in Qing Dynasty wrote the following: The second day is the Dragon Heads-raising Day. On the day, farmers and villagers made an ash path into the houses and kitchens, then wind around the water vats from the outside. This is called leading the dragons back to houses. People in the capital city fry broomcorn millet flour, cakes made of wheat flour and dates, husked wheat rice, and other things as their food. They call this "fumigating insects".

Dragons are auspicious omen, for which Chinese people have an admiration that bordered on worship. Dragons dominate wind and rain. So in ancient days, every time when there was a drought, people would make a straw dragon with sorghum stalks about one zhang (3.33 meters). Then in front of the straw dragon, four men carried the Dragon King’s memorial tablet on a tablet tray and in front of it, people perform acrobatics, singing and dancing, as walking on stilts, doing yangge dance, gongs, drums and flags leading the way. Everywhere contingent of parade passed, every family offered sacrifices, burned incenses and candles to worship the Dragon King. When the straw dragon passed by, people would carry buckets and sprinkle water over the straw dragon and the dragon dancers. They believe that the Dragon King would feel grateful and then make plentiful rain for the mankind.

好久没发C的文章了,偶然的机会看到一篇有意思的文章,主要讲解了函数式的宏,转载了过来。原文:转自这里。这位博主还有不少对C语言有趣深入的研究文章。

p>宏的预处理这个坑看起来浅,其实还蛮深的。它也是最容易被忽视的几个地方之一。这里斗胆来谈谈,说实话,在写这句话时我也不清楚这坑究竟有多深,没关系,我们摸着石头过河,一起看看到最后这坑能有多深!同时这篇文章也将会是《C语言编程艺术》中的一部分。

从一个相对简单的例子说起吧。

#define f(a,b) a##b
      #define g(a)   #a
      #define h(a) g(a)
      h(f(1,2))
      g(f(1,2))

相信不少人都见过这个例子。我们不妨再仔细分析一下它的解析过程。应该是这样的:

对于g(f(1,2)),预处理器看到的先是g,然后是(,说明这是一个函数式的宏,好,然后替换后面的实参f(1, 2),得到#f(1,2)(注:直接这么写非法,这里只是为了表示方便而已),因为它前面有个#,所以下一步是不会替换f的参数的!所以进一步得到"f(1, 2)",解析结束。而对于h(f(1,2)),预处理器看到的先是h,然后(,对其参数f(1, 2)进行替换,得到g(f(1,2)),注意这里的下一步是,预处理器就继续往后走,处理刚得到的f(1,2),而不是回过头去再处理g!得到12,到了这里我们的得到的是一个:g(12),然后重新扫描整个宏,替换g,最后得到"12"。

标准第6.10.3.1节中对此描述的还比较清晰,它这样写道:

After the arguments for the invocation of a function-like macro have been
identified, argument substitution takes place. A parameter in the replacement
list, unless preceded by a # or ## preprocessing token or followed by a ##
preprocessing token (see below), is replaced by the corresponding argument
after all macros contained therein have been expanded.

注意加粗的部分。到了在这里,我们可以简单总结一下函数式宏的基本替换流程:

首先要识别出这是一个函数式宏,通过什么?通过调用中出现的(,没错是左括号!到这里后下一步是参数替换,就是根据该宏的定义把实参全部替换进去,然后接着向后走,除非是遇到了#和##(正如上面例子中的g),把后面替换后的东西中如果还有已知宏的话,进行替换或者同样的展开,直到解析到末尾:所有的参数都已经替换完(或者#或##已经处理完);最后,预处理器还会对整个宏再进行一次扫描,因为前一轮替换中有可能在前面替换出一些新的东西来(比如上面例子中的h)。

这里咋看之下没什么问题,其实问题很多!为什么?因为宏替换不仅允许发生在“调用”宏的时候,而且还发生在它定义时!

问题1:宏的名字本身会被替换吗?

这个问题也可以这样问:宏允许被重新定义吗?不允许,但是允许相同的重新定义。标准这样写道:

An identifier currently defined as an object-like macro shall not be
redefined by another #define preprocessing directive unless the second definition
is an object-like macro definition and the two replacement lists are identical.
Likewise, an identifier currently defined as a function-like macro shall not be
redefined by another #define preprocessing directive unless the second definition
is a function-like macro definition that has the same number and spelling of
parameters, and the two replacement lists are identical.

问题2:宏的参数(形参)会被替换吗?

先举个例子说明这个问题:

#define foo 1
#define bar(foo) foo + 2
bar(a)

我们是得到a+2还是1+2?a+2!因为形参是不会被替换掉的,你想想啊,如果形参都被替换掉了这个宏就没什么作用了!那实参呢?实参会的,因为实参的替换发生在传递这个参数之前:

Before being substituted, each argument’s preprocessing tokens are
completely macro replaced as if they formed the rest of the preprocessing file

问题3:宏中参数之外的符号会被替换吗?

会,上面提到过“after all macros contained therein have been expanded”,也就是说这个发生在参数替换之前。但是,这里有个非常诡异的问题:如果被替换出来的符号正好和形参一样怎么办?就像下面这个例子:

#define foo bar
#define baz(bar) bar + foo
baz(1)

我们会得到1+1还是1+bar?后者,因为替换出来的那个bar是不会计算在形参之内的,虽然标准并没有明确这一点。想想吧,如果是的话那个宏的定义也会被破坏了!

另一个例子:

#define foo bar
#define mac(x) x(foo)
mac(foo)

根据上面所说,我们首先得到foo(foo),然后foo再被替换成bar,最后得到bar(bar)。

好了,到这里我们终于可以看一下更复杂的例子了:

#define m !(m)+n
#define n(n) n(m)
m(m)

这个例子相当复杂,是我见过的最复杂的一个宏。:-) 刚看到我们可能都有点蒙,没关系,咱们一步一步地来。

第一步很好走,第一个m直接被替换,得到:!(m)+n(m),别犹豫,接着往下走,替换最后一个m,得到:!(m)+n(!(m)+n),这时这一遍扫描已经完成。到这里我们得提出另外一个东西才能继续,你可能知道,递归。标准对此的描述是:

If the name of the macro being replaced is found during this scan of the
replacement list (not including the rest of the source file’s preprocessing
tokens), it is not replaced.

在上次替换中,被替换的是m,所以m在这里的再次出现将不会被替换,所以下一步是会替换第一个n,得到:!(m)+!(m)+n(m),注意这里又替换出一个新的m来,这个m会被替换,因为这次扫描���没完成!下一步得到:!(m)+!(m)+n(!(m)+n),第二遍扫描结束,全部的替换完成。

综上,我们可以总结出两条重要的宏替换规则:1)再复杂的宏也只是被扫描两遍,而且递归是不允许发生的,即使在第2遍时;2)一个替换完成后如果还没扫描完,要从被替换的那里继续。

(全文完)

This blog copyright 2009 by williamxue